//----------------------------------------------------------------------------------------
// @Project Includes
#include "includes.h"

//----------------------------------------------------------------------------------------
// @Local Macro Define in the module

//----------------------------------------------------------------------------------------
// @Local Type defines in the module

//----------------------------------------------------------------------------------------
// @Global Variables define in the module
stc_parm_t  g_stcParm;
const stc_parm_t SysConfigFactory =
{
    .stcSoc =
    {
        .u32maxLimitSOC = PARM_SOC_MAXSOC,
        .u32minLimitSOC = PARM_SOC_MINSOC,
    },
    .stcSwProtect =
    {
        .u16tov1        =  PARM_PROTECT_TOV1,
        .u16tovt1       =  PARM_PROTECT_TOVT1,
        .u16tovr1       =  PARM_PROTECT_TOVR1,
        .u16tovrt1      =  PARM_PROTECT_TOVRT1,
        .u16tov2        =  PARM_PROTECT_TOV2,
        .u16tovt2       =  PARM_PROTECT_TOVT2,
        .u16tovr2       =  PARM_PROTECT_TOVR2,
        .u16tovrt2      =  PARM_PROTECT_TOVRT2,
        .u16tov3        =  PARM_PROTECT_TOV3,
        .u16tovt3       =  PARM_PROTECT_TOVT3,
        .u16tovr3       =  PARM_PROTECT_TOVR3,
        .u16tovrt3      =  PARM_PROTECT_TOVRT3,
	
        .u16tuv1        =  PARM_PROTECT_TUV1,
        .u16tuvt1       =  PARM_PROTECT_TUVT1,
        .u16tuvr1       =  PARM_PROTECT_TUVR1,
        .u16tuvrt1      =  PARM_PROTECT_TUVRT1,
        .u16tuv2        =  PARM_PROTECT_TUV2,
        .u16tuvt2       =  PARM_PROTECT_TUVT2,
        .u16tuvr2       =  PARM_PROTECT_TUVR2,
        .u16tuvrt2      =  PARM_PROTECT_TUVRT2,
        .u16tuv3        =  PARM_PROTECT_TUV3,
        .u16tuvt3    	  =  PARM_PROTECT_TUVT3,
        .u16tuvr3       =  PARM_PROTECT_TUVR3,
        .u16tuvrt3      =  PARM_PROTECT_TUVRT3,
				
        .u16ov1         =  PARM_PROTECT_OV1,
        .u16ovt1        =  PARM_PROTECT_OVT1,
        .u16ovr1        =  PARM_PROTECT_OVR1,
        .u16ovrt1       =  PARM_PROTECT_OVRT1,
        .u16ov2         =  PARM_PROTECT_OV2,
        .u16ovt2        =  PARM_PROTECT_OVT2,
        .u16ovr2        =  PARM_PROTECT_OVR2,
        .u16ovrt2     	=  PARM_PROTECT_OVRT2,
        .u16ov3         =  PARM_PROTECT_OV3,
        .u16ovt3        =  PARM_PROTECT_OVT3,
        .u16ovr3        =  PARM_PROTECT_OVR3,
        .u16ovrt3       =  PARM_PROTECT_OVRT3,
	
        .u16uv1         =  PARM_PROTECT_UV1,
        .u16uvt1        =  PARM_PROTECT_UVT1,
        .u16uvr1        =  PARM_PROTECT_UVR1,
        .u16uvrt1       =  PARM_PROTECT_UVRT1,
        .u16uv2         =  PARM_PROTECT_UV2,
        .u16uvt2        =  PARM_PROTECT_UVT2,
        .u16uvr2        =  PARM_PROTECT_UVR2,
        .u16uvrt2       =  PARM_PROTECT_UVRT2,
        .u16uv3         =  PARM_PROTECT_UV3,
        .u16uvt3    	  =  PARM_PROTECT_UVT3,
        .u16uvr3        =  PARM_PROTECT_UVR3,
        .u16uvrt3       =  PARM_PROTECT_UVRT3,
	
        .u16balOpenV    =  PARM_PROTECT_BALOPENV,
        .u16balOpenD    =  PARM_PROTECT_BALOPEND,
        .u16balOpenT    =  PARM_PROTECT_BALOPENT,
        .u16balCloseV   =  PARM_PROTECT_BALCLOSEV,
        .u16balCloseD   =  PARM_PROTECT_BALCLOSED,
        .u16balCloseT   =  PARM_PROTECT_BALCLOSET,				
	
        .u16occv1       =  PARM_PROTECT_OCCV1,
        .u16occt1       =  PARM_PROTECT_OCCT1,
        .u16occrv1      =  PARM_PROTECT_OCCRV1,
        .u16occrt1    	=  PARM_PROTECT_OCCRT1,
        .u16occv2       =  PARM_PROTECT_OCCV2,
        .u16occt2       =  PARM_PROTECT_OCCT2,
        .u16occrv2    	=  PARM_PROTECT_OCCRV2,
        .u16occrt2   	  =  PARM_PROTECT_OCCRT2,	
        .u16occv3       =  PARM_PROTECT_OCCV3,
        .u16occt3       =  PARM_PROTECT_OCCT3,
        .u16occrv3      =  PARM_PROTECT_OCCRV3,
        .u16occrt3      =  PARM_PROTECT_OCCRT3,

        .u16ocdv1       =  PARM_PROTECT_OCDV1,
        .u16ocdt1       =  PARM_PROTECT_OCDT1,
        .u16ocdrv1      =  PARM_PROTECT_OCDRV1,
        .u16ocdrt1      =  PARM_PROTECT_OCDRT1,
        .u16ocdv2       =  PARM_PROTECT_OCDV2,
        .u16ocdt2       =  PARM_PROTECT_OCDT2,
        .u16ocdrv2      =  PARM_PROTECT_OCDRV2,
        .u16ocdrt2      =  PARM_PROTECT_OCDRT2,	
        .u16ocdv3       =  PARM_PROTECT_OCDV3,
        .u16ocdt3       =  PARM_PROTECT_OCDT3,
        .u16ocdrv3      =  PARM_PROTECT_OCDRV3,
        .u16ocdrt3      =  PARM_PROTECT_OCDRT3,

        .i16otc1        =  PARM_PROTECT_OTC1,
        .u16otct1       =  PARM_PROTECT_OTCT1,
        .i16otcr1       =  PARM_PROTECT_OTCR1,
        .u16otcrt1      =  PARM_PROTECT_OTCRT1,
        .i16otc2        =  PARM_PROTECT_OTC2,
        .u16otct2       =  PARM_PROTECT_OTCT2,
        .i16otcr2       =  PARM_PROTECT_OTCR2,
        .u16otcrt2      =  PARM_PROTECT_OTCRT2,
        .i16otc3        =  PARM_PROTECT_OTC3,
        .u16otct3       =  PARM_PROTECT_OTCT3,
        .i16otcr3       =  PARM_PROTECT_OTCR3,	
        .u16otcrt3    	=  PARM_PROTECT_OTCRT3,
	
        .i16utc1        =  PARM_PROTECT_UTC1,
        .u16utct1       =  PARM_PROTECT_UTCT1,
        .i16utcr1     	=  PARM_PROTECT_UTCR1,
        .u16utcrt1      =  PARM_PROTECT_UTCRT1,
        .i16utc2        =  PARM_PROTECT_UTC2,
        .u16utct2       =  PARM_PROTECT_UTCT2,
        .i16utcr2       =  PARM_PROTECT_UTCR2,
        .u16utcrt2      =  PARM_PROTECT_UTCRT2,
        .i16utc3        =  PARM_PROTECT_UTC3,
        .u16utct3       =  PARM_PROTECT_UTCT3,
        .i16utcr3       =  PARM_PROTECT_UTCR3,
        .u16utcrt3      =  PARM_PROTECT_UTCRT3,

        .i16otd1        =  PARM_PROTECT_OTD1,
        .u16otdt1       =  PARM_PROTECT_OTDT1,
        .i16otdr1       =  PARM_PROTECT_OTDR1,
        .u16otdrt1   	  =  PARM_PROTECT_OTDRT1,
        .i16otd2        =  PARM_PROTECT_OTD2,
        .u16otdt2       =  PARM_PROTECT_OTDT2,
        .i16otdr2       =  PARM_PROTECT_OTDR2,
        .u16otdrt2    	=  PARM_PROTECT_OTDRT2,
        .i16otd3        =  PARM_PROTECT_OTD3,
        .u16otdt3       =  PARM_PROTECT_OTDT3,
        .i16otdr3       =  PARM_PROTECT_OTDR3,
        .u16otdrt3    	=  PARM_PROTECT_OTDRT3,
	
        .i16utd1        =  PARM_PROTECT_UTD1,
        .u16utdt1       =  PARM_PROTECT_UTDT1,
        .i16utdr1       =  PARM_PROTECT_UTDR1,
        .u16utdrt1      =  PARM_PROTECT_UTDRT1,
        .i16utd2        =  PARM_PROTECT_UTD2,
        .u16utdt2       =  PARM_PROTECT_UTDT2,
        .i16utdr2     	=  PARM_PROTECT_UTDR2,	
        .u16utdrt2    	=  PARM_PROTECT_UTDRT2,
        .i16utd3        =  PARM_PROTECT_UTD3,
        .u16utdt3       =  PARM_PROTECT_UTDT3,
        .i16utdr3       =  PARM_PROTECT_UTDR3,
        .u16utdrt3      =  PARM_PROTECT_UTDRT3,

        .i16otcdm1      =  PARM_PROTECT_OTCDM1,
        .u16otcdmt1     =  PARM_PROTECT_OTCDMT1,
        .i16otcdmr1     =  PARM_PROTECT_OTCDMR1,	
        .u16otcdmrt1  	=  PARM_PROTECT_OTCDMRT1,
        .i16otcdm2   	  =  PARM_PROTECT_OTCDM2,
        .u16otcdmt2     =  PARM_PROTECT_OTCDMT2,
        .i16otcdmr2     =  PARM_PROTECT_OTCDMR2,	
        .u16otcdmrt2  	=  PARM_PROTECT_OTCDMRT2,
        .i16otcdm3      =  PARM_PROTECT_OTCDM3,
        .u16otcdmt3     =  PARM_PROTECT_OTCDMT3,
        .i16otcdmr3   	=  PARM_PROTECT_OTCDMR3,	
        .u16otcdmrt3  	=  PARM_PROTECT_OTCDMRT3,
				
        .i16utcdm1      =  PARM_PROTECT_UTCDM1,
        .u16utcdmt1     =  PARM_PROTECT_UTCDMT1,
        .i16utcdmr1     =  PARM_PROTECT_UTCDMR1,	
        .u16utcdmrt1  	=  PARM_PROTECT_UTCDMRT1,
        .i16utcdm2   	  =  PARM_PROTECT_UTCDM2,
        .u16utcdmt2     =  PARM_PROTECT_UTCDMT2,
        .i16utcdmr2     =  PARM_PROTECT_UTCDMR2,	
        .u16utcdmrt2  	=  PARM_PROTECT_UTCDMRT2,
        .i16utcdm3      =  PARM_PROTECT_UTCDM3,
        .u16utcdmt3     =  PARM_PROTECT_UTCDMT3,
        .i16utcdmr3   	=  PARM_PROTECT_UTCDMR3,	
        .u16utcdmrt3  	=  PARM_PROTECT_UTCDMRT3,	

        .i16otamb1      =  PARM_PROTECT_OTAMB1,
        .u16otambt1     =  PARM_PROTECT_OTAMBT1,
        .i16otambr1     =  PARM_PROTECT_OTAMBR1,	
        .u16otambrt1  	=  PARM_PROTECT_OTAMBRT1,
        .i16otamb2   	  =  PARM_PROTECT_OTAMB2,
        .u16otambt2     =  PARM_PROTECT_OTAMBT2,
        .i16otambr2     =  PARM_PROTECT_OTAMBR2,	
        .u16otambrt2  	=  PARM_PROTECT_OTAMBRT2,
        .i16otamb3      =  PARM_PROTECT_OTAMB3,
        .u16otambt3     =  PARM_PROTECT_OTAMBT3,
        .i16otambr3   	=  PARM_PROTECT_OTAMBR3,	
        .u16otambrt3  	=  PARM_PROTECT_OTAMBRT3,
				
        .i16utamb1      =  PARM_PROTECT_UTAMB1,
        .u16utambt1     =  PARM_PROTECT_UTAMBT1,
        .i16utambr1     =  PARM_PROTECT_UTAMBR1,	
        .u16utambrt1  	=  PARM_PROTECT_UTAMBRT1,
        .i16utamb2   	  =  PARM_PROTECT_UTAMB2,
        .u16utambt2     =  PARM_PROTECT_UTAMBT2,
        .i16utambr2     =  PARM_PROTECT_UTAMBR2,	
        .u16utambrt2  	=  PARM_PROTECT_UTAMBRT2,
        .i16utamb3      =  PARM_PROTECT_UTAMB3,
        .u16utambt3     =  PARM_PROTECT_UTAMBT3,
        .i16utambr3   	=  PARM_PROTECT_UTAMBR3,	
        .u16utambrt3  	=  PARM_PROTECT_UTAMBRT3,	
        	
        .u16diffvol1    =  PARM_PROTECT_DIFFVOL1,
        .u16diffvolt1   =  PARM_PROTECT_DIFFVOLT1,
        .u16diffvolr1   =  PARM_PROTECT_DIFFVOLR1,
        .u16diffvolrt1  =  PARM_PROTECT_DIFFVOLRT1,
        .u16diffvol2    =  PARM_PROTECT_DIFFVOL2,
        .u16diffvolt2   =  PARM_PROTECT_DIFFVOLT2,
        .u16diffvolr2   =  PARM_PROTECT_DIFFVOLR2,
        .u16diffvolrt2  =  PARM_PROTECT_DIFFVOLRT2,
        .u16diffvol3    =  PARM_PROTECT_DIFFVOL3,
        .u16diffvolt3   =  PARM_PROTECT_DIFFVOLT3,
        .u16diffvolr3   =  PARM_PROTECT_DIFFVOLR3,
        .u16diffvolrt3  =  PARM_PROTECT_DIFFVOLRT3,
				
        .u16difftemp1    =  PARM_PROTECT_DIFFTEMP1,
        .u16difftempt1   =  PARM_PROTECT_DIFFTEMPT1,
        .u16difftempr1   =  PARM_PROTECT_DIFFTEMPR1,
        .u16difftemprt1  =  PARM_PROTECT_DIFFTEMPRT1,
        .u16difftemp2    =  PARM_PROTECT_DIFFTEMP2,
        .u16difftempt2   =  PARM_PROTECT_DIFFTEMPT2,
        .u16difftempr2   =  PARM_PROTECT_DIFFTEMPR2,
        .u16difftemprt2  =  PARM_PROTECT_DIFFTEMPRT2,
        .u16difftemp3    =  PARM_PROTECT_DIFFTEMP3,
        .u16difftempt3   =  PARM_PROTECT_DIFFTEMPT3,
        .u16difftempr3   =  PARM_PROTECT_DIFFTEMPR3,
        .u16difftemprt3  =  PARM_PROTECT_DIFFTEMPRT3,	

        .u16soclow1    	 =  PARM_PROTECT_SOCLOW1,
        .u16soclowt1   	 =  PARM_PROTECT_SOCLOWT1,
        .u16soclowr1   	 =  PARM_PROTECT_SOCLOWR1,
        .u16soclowrt1  	 =  PARM_PROTECT_SOCLOWRT1,
        .u16soclow2    	 =  PARM_PROTECT_SOCLOW2,
        .u16soclowt2   	 =  PARM_PROTECT_SOCLOWT2,
        .u16soclowr2   	 =  PARM_PROTECT_SOCLOWR2,
        .u16soclowrt2  	 =  PARM_PROTECT_SOCLOWRT2,
        .u16soclow3    	 =  PARM_PROTECT_SOCLOW3,
        .u16soclowt3   	 =  PARM_PROTECT_SOCLOWT3,
        .u16soclowr3   	 =  PARM_PROTECT_SOCLOWR3,
        .u16soclowrt3  	 =  PARM_PROTECT_SOCLOWRT3,	
				
    },
    .stcHwProtect =
    {
        .u16ov         =  PARM_PROTECT_OV,
        .u16ovt        =  PARM_PROTECT_OVT,
        .u16ovr        =  PARM_PROTECT_OVR,
        .u16ovrt       =  PARM_PROTECT_OVRT,
        .u16uv         =  PARM_PROTECT_UV,
        .u16uvt        =  PARM_PROTECT_UVT,
        .u16uvr        =  PARM_PROTECT_UVR,
        .u16uvrt       =  PARM_PROTECT_UVRT,
		
        .u16occv       =  PARM_PROTECT_OCCV,
        .u16occt       =  PARM_PROTECT_OCCT,
        .u16occrv      =  PARM_PROTECT_OCCRV,
        .u16occrt    	 =  PARM_PROTECT_OCCRT,
        .u16ocdv       =  PARM_PROTECT_OCDV,
        .u16ocdt       =  PARM_PROTECT_OCDT,
        .u16ocdrv      =  PARM_PROTECT_OCDRV,
        .u16ocdrt      =  PARM_PROTECT_OCDRT,

				.u16scv      	 =  PARM_PROTECT_SCV,
				.u16sct      	 =  PARM_PROTECT_SCT,		
			
        .i16otc        =  PARM_PROTECT_OTC,
        .u16otct       =  PARM_PROTECT_OTCT,
        .i16otcr       =  PARM_PROTECT_OTCR,
        .u16otcrt      =  PARM_PROTECT_OTCRT,
        .i16utc        =  PARM_PROTECT_UTC,
        .u16utct       =  PARM_PROTECT_UTCT,
        .i16utcr     	 =  PARM_PROTECT_UTCR,
        .u16utcrt      =  PARM_PROTECT_UTCRT,

        .i16otd        =  PARM_PROTECT_OTD,
        .u16otdt       =  PARM_PROTECT_OTDT,
        .i16otdr       =  PARM_PROTECT_OTDR,
        .u16otdrt   	 =  PARM_PROTECT_OTDRT,
        .i16utd        =  PARM_PROTECT_UTD,
        .u16utdt       =  PARM_PROTECT_UTDT,
        .i16utdr       =  PARM_PROTECT_UTDR,
        .u16utdrt      =  PARM_PROTECT_UTDRT,

    },		
    .stcConfig =
    {
        .u8curSw 	     = PARM_CONFIG_S_CUR_SW,
        .u16curThr 	   = PARM_CONFIG_S_CUR_THR,
        .u16curTime 	 = PARM_CONFIG_S_CUR_TIME,

        .u32designCap	 = PARM_CONFIG_CAPACITYVALUE,
        .u32fullChgCap = PARM_CONFIG_CAPACITYVALUE,
        
        .u16cycleCount = PARM_CONFIG_RECHARGECYCLES,
        .u16perChgVol  = PARM_CONFIG_PRECHARGEVOL,
        .u8afeType 	   = PARM_CONFIG_AFETYPE,
        .u8invType 	   = PARM_CONFIG_INVTYPE,		
        .u8batteryType = PARM_CONFIG_BATTERYTYPE,      
        
        .u8cellS	     = PARM_CONFIG_CELLNUMS,
        .u8cellP 	     = PARM_CONFIG_CELLNUMP,
				.u8swProtectEn = PARM_CONFIG_SW_PROTECT_EN,
				.u8capAutoLearn= PARM_CONFIG_CAP_AUTOLEARN,
			
				.u16samplingResistor  	= PARM_CONFIG_SAMPLING_RESISTOR,
				.u16currRatioCharge   	= PARM_CONFIG_CURR_RATCHG,
				.u16currRatioDisCharge	= PARM_CONFIG_CURR_RATDIS,
				.i16currZeroOffSetADVal	= PARM_CONFIG_CURR_ZEROOFFSETVAL,			
			
        //.cdevSn[32];
				.u8chgCabType 						= PARM_CONFIG_CHGCAB_TYPE,
				.u8commuAddr 							= PARM_CONFIG_COMMU_ADDR,
				.u16forbidChgVol 					= PARM_CONFIG_FORBIDCHGVOL,
				.u16maxChgCur 						= PARM_CONFIG_MAXCHGCUR,
				.u8forbidBalHightTempThr 	= PARM_CONFIG_FORBIDBALHIGHTTEMPTHR,
				.u8forbidBalLowTempThr 		= PARM_CONFIG_FORBIDBALLOWTEMPTHR,
				.u16fullChgVol 						= PARM_CONFIG_FULLCHGVOL,
				.u16fullChgCur 						= PARM_CONFIG_FULLCHGCUR,
				.u16fullChgDuration 			= PARM_CONFIG_FULLCHGDURATION,
				.u32modFunc 							= PARM_CONFIG_MODFUNC,
				.u32rank2Func 						= PARM_CONFIG_RANK2FUNC,				
				.u32rank1Func 						= PARM_CONFIG_RANK1FUNC,
				.u16dispSoc 							= PARM_CONFIG_DISPSOC,
				.u16trueSoc 							= PARM_CONFIG_TRUESOC,				
				.u16socInterval 					= PARM_CONFIG_SOCINTERVAL,
				.u8soh 										= PARM_CONFIG_SOH,
				.u16designVol 						= PARM_CONFIG_DESIGNVOL,
				.u32remainCap 						= PARM_CONFIG_REMAINCAP,
				.u32accChgCap 						= PARM_CONFIG_ACCCHGCAP,
				.u32accDsgCap 						= PARM_CONFIG_ACCDSGCAP,
				
    },
    .u16checkCRC = 0,
    .u32saveTail = PARM_CONFIG_SAVE_TAIL,
};
//----------------------------------------------------------------------------------------
// @Prototypes of functions in the module
static bool_t srv_parm_check(stc_parm_t sysconfig);
static bool_t srv_parm_saves(void);
static bool_t srv_parm_read(void);
static void srv_parm_afeDefault(void);

//========================================================================================

/**
 * @brief  srv parameter initialization
 * @param  none
 * @return none
 * @note   none
 */
static bool_t srv_parm_check(stc_parm_t  sysparm)
{
    uint32_t ui16crc;
    uint32_t ui16checkCrc;

    ui16crc = sysparm.u16checkCRC;

    sysparm.u16checkCRC = 0;

    ui16checkCrc = srv_crc16_system((uint8_t*)&sysparm,sizeof(stc_parm_t),0);
    sysparm.u16checkCRC = ui16crc;

    if((ui16checkCrc == ui16crc)&&(sysparm.u32saveTail == PARM_CONFIG_SAVE_TAIL))
    {
        return true;
    }
    return false;
}

/**
 * @brief  srv parameter save
 * @param  none
 * @return true false
 * @note   none
 */
bool_t srv_parm_saves(void)
{
    static stc_parm_t sysparm;
	
    g_stcParm.u16checkCRC = 0;
    g_stcParm.u32saveTail = PARM_CONFIG_SAVE_TAIL;
    g_stcParm.u16checkCRC = srv_crc16_system((uint8_t*)&g_stcParm,sizeof(g_stcParm),0);

    drv_flash_write((uint8_t*)&g_stcParm, DEVICE_CONFIG_PRAM_ADDR,sizeof(g_stcParm));
    memset(&sysparm,0,sizeof(sysparm));
    drv_flash_read((uint8_t*)&sysparm,DEVICE_CONFIG_PRAM_ADDR,sizeof(sysparm));
	
    if(memcmp((uint8_t*)&sysparm,(uint8_t*)&g_stcParm,sizeof(g_stcParm)) == 0)
    {
        SYSTEM_DEBUG("SYS:<< config Write SysConfig success! \r\n");
        return true;
    }
    SYSTEM_DEBUG("SYS:<< config Write SysConfig error! \r\n");
    return false;
}

/**
 * @brief  srv parameter read
 * @param  none
 * @return true false
 * @note   none
 */
bool_t srv_parm_read(void)
{
    drv_flash_read((uint8_t*)&g_stcParm,DEVICE_CONFIG_PRAM_ADDR,sizeof(g_stcParm));

    if(true == srv_parm_check(g_stcParm))
    {
        SYSTEM_DEBUG("SYS:<< config Read SysConfig successfully! \r\n");
        return true;
    }
    else
    {
        SYSTEM_DEBUG("SYS:<< config Read SysConfig Errors! \r\n");
        return false;
    }
}


/**
 * @brief  srv parameter afe (sh367309) default
 * @param  none
 * @return true false
 * @note   none
 */
void srv_parm_afeDefault(void)
{

}

/**
 * @brief  srv parameter one key
 * @param  none
 * @return true false
 * @note   none
 */
void srv_parm_oneKey(void)
{
    if (g_stcParm.stcConfig.u8batteryType == TERNARY_MATERIAL_BATTERY_TYPE)
	  {
				g_stcParm.stcSwProtect.u16ov1= 4150;
				g_stcParm.stcSwProtect.u16ovr1 = 4100;
				g_stcParm.stcSwProtect.u16ov2= 4250;
				g_stcParm.stcSwProtect.u16ovr2 = 4150;
				g_stcParm.stcSwProtect.u16ov3= 4300;
				g_stcParm.stcSwProtect.u16ovr3 = 4250;

				g_stcParm.stcSwProtect.u16uv1= 3000;
				g_stcParm.stcSwProtect.u16uvr1 = 3050;
				g_stcParm.stcSwProtect.u16uv2= 2500;
				g_stcParm.stcSwProtect.u16uvr2 = 3000;
				g_stcParm.stcSwProtect.u16uv3= 2300;
				g_stcParm.stcSwProtect.u16uvr3 = 2500;	
	  }
	  else
	  {
        g_stcParm.stcSwProtect.u16ov1= PARM_PROTECT_OV1;
        g_stcParm.stcSwProtect.u16ovr1 = PARM_PROTECT_OVR1;
        g_stcParm.stcSwProtect.u16ov2= PARM_PROTECT_OV2;
        g_stcParm.stcSwProtect.u16ovr2 = PARM_PROTECT_OVR2;
        g_stcParm.stcSwProtect.u16ov3= PARM_PROTECT_OV3;
        g_stcParm.stcSwProtect.u16ovr3 = PARM_PROTECT_OVR3;
        
        g_stcParm.stcSwProtect.u16uv1= PARM_PROTECT_UV1;
        g_stcParm.stcSwProtect.u16uvr1 = PARM_PROTECT_UVR1;
        g_stcParm.stcSwProtect.u16uv2= PARM_PROTECT_UV2;
        g_stcParm.stcSwProtect.u16uvr2 = PARM_PROTECT_UVR2;
        g_stcParm.stcSwProtect.u16uv3= PARM_PROTECT_UV3;
        g_stcParm.stcSwProtect.u16uvr3 = PARM_PROTECT_UVR3;	
	  }

}

/**
 * @brief  srv parameter default factory
 * @param  none
 * @return true false
 * @note   none
 */
bool_t srv_parm_defaultFactory(uint8_t type)
{
    uint8_t cdevSn[32];
		uint8_t cfactorySn[20];
		uint8_t cprojectSn[20];
		uint8_t cbatterySn[20];
		uint8_t ciccidSn[20];
		uint8_t cimeiSn[20];	
		uint8_t cpasswordSn[30];

	  int16_t temp_cal[8];
	  int16_t vol_cal[32];
	

    memcpy(cdevSn,g_stcParm.stcConfig.cdevSn,32);
    memcpy(cfactorySn,g_stcParm.stcConfig.cfactorySn,20);	
    memcpy(cprojectSn,g_stcParm.stcConfig.cprojectSn,20);	
    memcpy(cbatterySn,g_stcParm.stcConfig.cbatterySn,20);
    memcpy(ciccidSn,g_stcParm.stcConfig.ciccidSn,20);
    memcpy(cimeiSn,g_stcParm.stcConfig.cimeiSn,20);
    memcpy(cpasswordSn,g_stcParm.stcConfig.cpasswordSn,30);
	
    memcpy(temp_cal,g_stcParm.stcCal.i16temperature,16);
    memcpy(vol_cal,g_stcParm.stcCal.i16voltage,64);

    memcpy(&g_stcParm,&SysConfigFactory,sizeof(stc_parm_t));
    if (type == 0)
    {
			  g_stcParm.stcConfig.cdevSn[0] = sizeof(g_stcParm.stcConfig.cdevSn)-1;
        memcpy(&g_stcParm.stcConfig.cdevSn[1],PARM_CONFIG_DEVSN,strlen(PARM_CONFIG_DEVSN));
			  g_stcParm.stcConfig.cfactorySn[0] = sizeof(g_stcParm.stcConfig.cfactorySn)-1;
        memcpy(&g_stcParm.stcConfig.cfactorySn[1],PARM_CONFIG_FACTORYSN,strlen(PARM_CONFIG_FACTORYSN));	
				g_stcParm.stcConfig.cprojectSn[0] = sizeof(g_stcParm.stcConfig.cprojectSn)-1;			
        memcpy(&g_stcParm.stcConfig.cprojectSn[1],PARM_CONFIG_PROJECTSN,strlen(PARM_CONFIG_PROJECTSN));
				g_stcParm.stcConfig.cbatterySn[0] = sizeof(g_stcParm.stcConfig.cbatterySn)-1;				
        memcpy(&g_stcParm.stcConfig.cbatterySn[1],PARM_CONFIG_BATTERYSN,strlen(PARM_CONFIG_BATTERYSN));
				g_stcParm.stcConfig.ciccidSn[0] = sizeof(g_stcParm.stcConfig.ciccidSn)-1;				
        memcpy(&g_stcParm.stcConfig.ciccidSn[1],PARM_CONFIG_ICCIDSN,strlen(PARM_CONFIG_ICCIDSN));
				g_stcParm.stcConfig.cimeiSn[0] = sizeof(g_stcParm.stcConfig.cimeiSn)-1;				
        memcpy(&g_stcParm.stcConfig.cimeiSn[1],PARM_CONFIG_IMEISN,strlen(PARM_CONFIG_IMEISN));
			
        memcpy(g_stcParm.stcConfig.cpasswordSn,PARM_CONFIG_PASSWORDSN,strlen(PARM_CONFIG_PASSWORDSN));			
			
        memset(g_stcParm.stcCal.i16temperature,PARM_CAL_TEMP,16);	
        memset(g_stcParm.stcCal.i16voltage,PARM_CAL_VOLTAGE,64);
    }
    else
    {
        memcpy(g_stcParm.stcConfig.cdevSn,&cdevSn[0],32);
        memcpy(g_stcParm.stcConfig.cfactorySn,&cfactorySn[0],20);			
        memcpy(g_stcParm.stcConfig.cprojectSn,&cprojectSn[0],20);
        memcpy(g_stcParm.stcConfig.cbatterySn,&cbatterySn[0],20);
        memcpy(g_stcParm.stcConfig.ciccidSn,&ciccidSn[0],20);			
        memcpy(g_stcParm.stcConfig.cimeiSn,&cimeiSn[0],20);
        memcpy(g_stcParm.stcConfig.cpasswordSn,&cpasswordSn[0],30);
        memcpy(g_stcParm.stcCal.i16temperature,&temp_cal[0],16);
	      memcpy(g_stcParm.stcCal.i16voltage,&vol_cal[0],64);
    }
	
    memset(g_stcParm.u8bakByte,0,sizeof(g_stcParm.u8bakByte));
    memset(g_stcParm.u16bakWord,0,sizeof(g_stcParm.u16bakWord));
    memset(g_stcParm.u32bakDWord,0,sizeof(g_stcParm.u32bakDWord));
		
		srv_parm_readRegRefresh();
    return (srv_parm_saves());
}

/**
 * @brief  srv parameter save check
 * @param  none
 * @return true false
 * @note   none
 */
bool_t srv_parm_saveCheck(void)
{
    bool_t ret = false;
    switch(srv_parm_saves())
    {
        case true:
            ret = srv_parm_read();
            break;
			
        case false:
            srv_parm_read();
            ret = false;
            break;

        default:
            break;
    }
		srv_parm_readRegRefresh();		
    return ret;
}

/**
 * @brief  srv parameter initialization
 * @param  none
 * @return none
 * @note   none
 */
void srv_parm_init(void)
{
    //srv_parm_defaultFactory();
    if(true != srv_parm_read())
    {
        switch(srv_parm_defaultFactory(0))
        {
            case false:
                srv_parm_saves();
                break;
            default:
                break;
        }
    }
    srv_parm_afeDefault();
		srv_parm_readRegRefresh();	
		
}

/**
 * @brief  srv parameter change check
 * @param  none
 * @return none
 * @note   none
 */
void srv_parm_changeCheck(void)
{
	  if (g_stcParm.stcConfig.u32fullChgCap != g_stcVar.u32fullChgCap)
		{
				g_stcVar.u32fullChgCap = g_stcParm.stcConfig.u32fullChgCap;			
				//app_soc_init();		
		}
		
	  if (g_stcParm.stcConfig.u8cellS != g_stcVar.u8cellS)
		{
				g_stcVar.u8cellS = g_stcParm.stcConfig.u8cellS;
		    srv_parm_writeRegRefresh();
		    srv_parm_saveCheck();			
				NVIC_SystemReset();	
		}
		
	  if (g_stcParm.stcConfig.u8batteryType != g_stcVar.u8batteryType)
		{
				g_stcVar.u8batteryType = g_stcParm.stcConfig.u8batteryType;
				srv_parm_oneKey();
				srv_parm_saveCheck();
				NVIC_SystemReset();	
		}
		
    if (g_stcParm.stcConfig.u8capAutoLearn != g_stcSoc.bfullChgCapAutoLearnFlag)
    {
       g_stcParm.stcConfig.u8capAutoLearn = g_stcSoc.bfullChgCapAutoLearnFlag;
       srv_parm_saveCheck();			
    }
		
		/*check pc write state*/
    if (g_stcVar.bparmWriteFlag == true)
		{
			  if (g_stcVar.u16parmWriteWaitTime)
				{
						g_stcVar.u16parmWriteWaitTime--;
				}
				else
				{
						g_stcVar.bparmWriteFlag = false;
					  srv_parm_writeRegRefresh();
						srv_parm_saveCheck();
				}
		}				
}

/**
 * @brief  read reg parm refresh
 * @param  
 * @return 
 * @note   
 */
void srv_parm_readRegRefresh(void)
{
    uint8_t u8Temp[40];
	  uint8_t u8i;
	
		memset((void *) u8Temp, 0x20, 30); 
	  memcpy(u8Temp,BMS_SW_VERSION,sizeof(BMS_SW_VERSION));
	  for (u8i = 0; u8i < 15; u8i++)
		{
			g_u16RegParm[REG_BASIC_SW_VER+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}
		
		memset((void *) u8Temp, 0x20, 30); 
	  memcpy(u8Temp,BMS_HW_VERSION,sizeof(BMS_HW_VERSION));
	  for (u8i = 0; u8i < 15; u8i++)
		{
			g_u16RegParm[REG_BASIC_HW_VER+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}		
	
		memset((void *) u8Temp, 0x20, 32);
		u8Temp[0] = g_stcParm.stcConfig.cdevSn[0];
	  memcpy(&u8Temp[1],&g_stcParm.stcConfig.cdevSn[1],sizeof(g_stcParm.stcConfig.cdevSn)-1);
	  for (u8i = 0; u8i < 16; u8i++)
		{
			g_u16RegParm[REG_BASIC_DEVIC_ID+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}			
	
		memset((void *) u8Temp, 0x20, 20);
	  u8Temp[0] = g_stcParm.stcConfig.cfactorySn[0];
	  memcpy(&u8Temp[1],&g_stcParm.stcConfig.cfactorySn[1],sizeof(g_stcParm.stcConfig.cfactorySn)-1);
	  for (u8i = 0; u8i < 10; u8i++)
		{
			g_u16RegParm[REG_BASIC_FACTORY_ID+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}			
	
		memset((void *) u8Temp, 0x20, 20);
		u8Temp[0] = g_stcParm.stcConfig.cprojectSn[0];
	  memcpy(&u8Temp[1],&g_stcParm.stcConfig.cprojectSn[1],sizeof(g_stcParm.stcConfig.cprojectSn)-1);
	  for (u8i = 0; u8i < 10; u8i++)
		{
			g_u16RegParm[REG_BASIC_PROJECT_CODE+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}			
		
		memset((void *) u8Temp, 0x20, 20);
		u8Temp[0] = g_stcParm.stcConfig.cbatterySn[0];
	  memcpy(&u8Temp[1],&g_stcParm.stcConfig.cbatterySn[1],sizeof(g_stcParm.stcConfig.cbatterySn)-1);
	  for (u8i = 0; u8i < 10; u8i++)
		{
			g_u16RegParm[REG_BASIC_BATTERY_NUM+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}			
		
		memset((void *) u8Temp, 0x20, 20);
		u8Temp[0] = g_stcParm.stcConfig.ciccidSn[0];
	  memcpy(&u8Temp[1],&g_stcParm.stcConfig.ciccidSn[1],sizeof(g_stcParm.stcConfig.ciccidSn)-1);
	  for (u8i = 0; u8i < 10; u8i++)
		{
			g_u16RegParm[REG_BASIC_ICCID_NUM+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}		
		
		memset((void *) u8Temp, 0x20, 20);
		u8Temp[0] = g_stcParm.stcConfig.cimeiSn[0];
	  memcpy(&u8Temp[1],&g_stcParm.stcConfig.cimeiSn[1],sizeof(g_stcParm.stcConfig.cimeiSn)-1);
	  for (u8i = 0; u8i < 10; u8i++)
		{
			g_u16RegParm[REG_BASIC_IMEI_NUM+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}	
		
		memset((void *) u8Temp, 0x20, 30);
	  memcpy(&u8Temp[0],g_stcParm.stcConfig.cpasswordSn,sizeof(g_stcParm.stcConfig.cpasswordSn));
		for (u8i = 0; u8i < 15; u8i++)
		{
			g_u16RegParm[REG_BASIC_PASSWORD+u8i] = (((uint16_t)u8Temp[0+2*u8i] << 8) | ((uint16_t)u8Temp[1+2*u8i]));
		}	
		
	  drv_rtc_getTime(&u8Temp[0]);
		g_u16RegParm[REG_BASIC_RTC_TIME] = (((uint16_t)u8Temp[0] << 8) | ((uint16_t)u8Temp[1]));
		g_u16RegParm[REG_BASIC_RTC_TIME + 1] = (((uint16_t)u8Temp[2] << 8) | ((uint16_t)u8Temp[3]));
		g_u16RegParm[REG_BASIC_RTC_TIME + 2] = (((uint16_t)u8Temp[4] << 8) | ((uint16_t)u8Temp[5]));
		
		g_u16RegParm[REG_CONFIG_CURSW]	= (uint16_t)g_stcParm.stcConfig.u8curSw;	
		g_u16RegParm[REG_CONFIG_CURTHR]	= (uint16_t)g_stcParm.stcConfig.u16curThr;	
		g_u16RegParm[REG_CONFIG_CURTIME]	= (uint16_t)g_stcParm.stcConfig.u16curTime;	
		g_u16RegParm[REG_CONFIG_CYCLECOUNT]	= (uint16_t)g_stcParm.stcConfig.u16cycleCount;			
		g_u16RegParm[REG_CONFIG_PERCHGVOL]	= (uint16_t)g_stcParm.stcConfig.u16perChgVol;			
		g_u16RegParm[REG_CONFIG_AFETYPE]	= (uint16_t)g_stcParm.stcConfig.u8afeType;	
		g_u16RegParm[REG_CONFIG_INVTYPE]	= (uint16_t)g_stcParm.stcConfig.u8invType;	
		g_u16RegParm[REG_CONFIG_BATTERYTYPE]	= (uint16_t)g_stcParm.stcConfig.u8batteryType;	
		g_u16RegParm[REG_CONFIG_CELLS]	= (uint16_t)g_stcParm.stcConfig.u8cellS;	
		g_u16RegParm[REG_CONFIG_CELLP]	= (uint16_t)g_stcParm.stcConfig.u8cellP;
		g_u16RegParm[REG_CONFIG_CHGCAB]	= (uint16_t)g_stcParm.stcConfig.u8chgCabType;		
		g_u16RegParm[REG_CONFIG_COMMUADDR]	= (uint16_t)g_stcParm.stcConfig.u8commuAddr;
		g_u16RegParm[REG_CONFIG_FORBIDCHGVOL]	= (uint16_t)g_stcParm.stcConfig.u16forbidChgVol;
		g_u16RegParm[REG_CONFIG_MAXCHGCUR]	= (uint16_t)g_stcParm.stcConfig.u16maxChgCur;
		g_u16RegParm[REG_CONFIG_FORBIDBALHIGHTTEMPTHR]	= (uint16_t)g_stcParm.stcConfig.u8forbidBalHightTempThr + TEMP_OFFSET;
		g_u16RegParm[REG_CONFIG_FORBIDBALLOWTEMPTHR]	= (uint16_t)g_stcParm.stcConfig.u8forbidBalLowTempThr + TEMP_OFFSET;	
		g_u16RegParm[REG_CONFIG_FULLCHGVOL]	= (uint16_t)g_stcParm.stcConfig.u16fullChgVol;	
		g_u16RegParm[REG_CONFIG_FULLCHGCUR]	= (uint16_t)g_stcParm.stcConfig.u16fullChgCur;
		g_u16RegParm[REG_CONFIG_FULLCHGDURATION]	= (uint16_t)g_stcParm.stcConfig.u16fullChgDuration;
		
		g_u16RegParm[REG_CONFIG_MODFUNC]	= (uint16_t)(g_stcParm.stcConfig.u32modFunc >> 0);	
		g_u16RegParm[REG_CONFIG_MODFUNC+1]	= (uint16_t)(g_stcParm.stcConfig.u32modFunc >> 16);
		
		g_u16RegParm[REG_CONFIG_RANK2FUNC]	= (uint16_t)(g_stcParm.stcConfig.u32rank2Func >> 0);	
		g_u16RegParm[REG_CONFIG_RANK2FUNC+1]	= (uint16_t)(g_stcParm.stcConfig.u32rank2Func >> 16);				
		g_u16RegParm[REG_CONFIG_RANK1FUNC]	= (uint16_t)(g_stcParm.stcConfig.u32rank1Func >> 0);	
		g_u16RegParm[REG_CONFIG_RANK1FUNC+1]	= (uint16_t)(g_stcParm.stcConfig.u32rank1Func >> 16);			
	
		g_u16RegParm[REG_CONFIG_SAMPRESISTOR]	= (uint16_t)g_stcParm.stcConfig.u16samplingResistor;	
		g_u16RegParm[REG_CONFIG_DISPSOC]	= (uint16_t)g_stcParm.stcConfig.u16dispSoc;
		g_u16RegParm[REG_CONFIG_TRUESOC]	= (uint16_t)g_stcParm.stcConfig.u16trueSoc;			
		g_u16RegParm[REG_CONFIG_SOCINTERVAL]	= (uint16_t)g_stcParm.stcConfig.u16socInterval;	
		g_u16RegParm[REG_CONFIG_SOH]	= (uint16_t)g_stcParm.stcConfig.u8soh;			
		g_u16RegParm[REG_CONFIG_DESIGNVOL]	= (uint16_t)g_stcParm.stcConfig.u16designVol;	
		
    g_u16RegParm[REG_CONFIG_DESIGNCAP]	= (uint16_t)(g_stcParm.stcConfig.u32designCap >> 16);		
		g_u16RegParm[REG_CONFIG_DESIGNCAP+1]	= (uint16_t)(g_stcParm.stcConfig.u32designCap >> 0);			
		g_u16RegParm[REG_CONFIG_FULLCHGCAP]	= (uint16_t)(g_stcParm.stcConfig.u32fullChgCap >> 16);		
		g_u16RegParm[REG_CONFIG_FULLCHGCAP+1]	= (uint16_t)(g_stcParm.stcConfig.u32fullChgCap >> 0);
    g_u16RegParm[REG_CONFIG_REMAINCAP]	= (uint16_t)(g_stcParm.stcConfig.u32remainCap >> 16);		
		g_u16RegParm[REG_CONFIG_REMAINCAP+1]	= (uint16_t)(g_stcParm.stcConfig.u32remainCap >> 0);		
    g_u16RegParm[REG_CONFIG_ACCCHGCAP]	= (uint16_t)(g_stcParm.stcConfig.u32accChgCap >> 16);		
		g_u16RegParm[REG_CONFIG_ACCCHGCAP+1]	= (uint16_t)(g_stcParm.stcConfig.u32accChgCap >> 0);	
    g_u16RegParm[REG_CONFIG_ACCDSGCAP]	= (uint16_t)(g_stcParm.stcConfig.u32accDsgCap >> 16);		
		g_u16RegParm[REG_CONFIG_ACCDSGCAP+1]	= (uint16_t)(g_stcParm.stcConfig.u32accDsgCap >> 0);			

		g_u16RegParm[REG_PROTECT_OV1]	= (uint16_t)g_stcParm.stcSwProtect.u16ov1;
		g_u16RegParm[REG_PROTECT_OVT1]	= (uint16_t)g_stcParm.stcSwProtect.u16ovt1;
		g_u16RegParm[REG_PROTECT_OVR1]	= (uint16_t)g_stcParm.stcSwProtect.u16ovr1;
		g_u16RegParm[REG_PROTECT_OVRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16ovrt1;		
		g_u16RegParm[REG_PROTECT_OV2]	= (uint16_t)g_stcParm.stcSwProtect.u16ov2;
		g_u16RegParm[REG_PROTECT_OVT2]	= (uint16_t)g_stcParm.stcSwProtect.u16ovt2;
		g_u16RegParm[REG_PROTECT_OVR2]	= (uint16_t)g_stcParm.stcSwProtect.u16ovr2;
		g_u16RegParm[REG_PROTECT_OVRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16ovrt2;
		g_u16RegParm[REG_PROTECT_OV3]	= (uint16_t)g_stcParm.stcSwProtect.u16ov3;
		g_u16RegParm[REG_PROTECT_OVT3]	= (uint16_t)g_stcParm.stcSwProtect.u16ovt3;
		g_u16RegParm[REG_PROTECT_OVR3]	= (uint16_t)g_stcParm.stcSwProtect.u16ovr3;
		g_u16RegParm[REG_PROTECT_OVRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16ovrt3;
		g_u16RegParm[REG_PROTECT_UV1]	= (uint16_t)g_stcParm.stcSwProtect.u16uv1;
		g_u16RegParm[REG_PROTECT_UVT1]	= (uint16_t)g_stcParm.stcSwProtect.u16uvt1;
		g_u16RegParm[REG_PROTECT_UVR1]	= (uint16_t)g_stcParm.stcSwProtect.u16uvr1;
		g_u16RegParm[REG_PROTECT_UVRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16uvrt1;		
		g_u16RegParm[REG_PROTECT_UV2]	= (uint16_t)g_stcParm.stcSwProtect.u16uv2;
		g_u16RegParm[REG_PROTECT_UVT2]	= (uint16_t)g_stcParm.stcSwProtect.u16uvt2;
		g_u16RegParm[REG_PROTECT_UVR2]	= (uint16_t)g_stcParm.stcSwProtect.u16uvr2;
		g_u16RegParm[REG_PROTECT_UVRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16uvrt2;
		g_u16RegParm[REG_PROTECT_UV3]	= (uint16_t)g_stcParm.stcSwProtect.u16uv3;
		g_u16RegParm[REG_PROTECT_UVT3]	= (uint16_t)g_stcParm.stcSwProtect.u16uvt3;
		g_u16RegParm[REG_PROTECT_UVR3]	= (uint16_t)g_stcParm.stcSwProtect.u16uvr3;
		g_u16RegParm[REG_PROTECT_UVRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16uvrt3;	
		g_u16RegParm[REG_PROTECT_BALOPENV]	= (uint16_t)g_stcParm.stcSwProtect.u16balOpenV;
		g_u16RegParm[REG_PROTECT_BALOPEND]	= (uint16_t)g_stcParm.stcSwProtect.u16balOpenD;
		g_u16RegParm[REG_PROTECT_BALOPENT]	= (uint16_t)g_stcParm.stcSwProtect.u16balOpenT;
		g_u16RegParm[REG_PROTECT_BALCLOSEV]	= (uint16_t)g_stcParm.stcSwProtect.u16balCloseV;
		g_u16RegParm[REG_PROTECT_BALCLOSED]	= (uint16_t)g_stcParm.stcSwProtect.u16balCloseD;
		g_u16RegParm[REG_PROTECT_BALCLOSET]	= (uint16_t)g_stcParm.stcSwProtect.u16balCloseT;		
		g_u16RegParm[REG_PROTECT_OCCV1]	= (uint16_t)g_stcParm.stcSwProtect.u16occv1;
		g_u16RegParm[REG_PROTECT_OCCT1]	= (uint16_t)g_stcParm.stcSwProtect.u16occt1;
		g_u16RegParm[REG_PROTECT_OCCRV1]	= (uint16_t)g_stcParm.stcSwProtect.u16occrv1;
		g_u16RegParm[REG_PROTECT_OCCRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16occrt1;
		g_u16RegParm[REG_PROTECT_OCCV2]	= (uint16_t)g_stcParm.stcSwProtect.u16occv2;
		g_u16RegParm[REG_PROTECT_OCCT2]	= (uint16_t)g_stcParm.stcSwProtect.u16occt2;
		g_u16RegParm[REG_PROTECT_OCCRV2]	= (uint16_t)g_stcParm.stcSwProtect.u16occrv2;
		g_u16RegParm[REG_PROTECT_OCCRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16occrt2;	
		g_u16RegParm[REG_PROTECT_OCCV3]	= (uint16_t)g_stcParm.stcSwProtect.u16occv3;
		g_u16RegParm[REG_PROTECT_OCCT3]	= (uint16_t)g_stcParm.stcSwProtect.u16occt3;
		g_u16RegParm[REG_PROTECT_OCCRV3]	= (uint16_t)g_stcParm.stcSwProtect.u16occrv3;
		g_u16RegParm[REG_PROTECT_OCCRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16occrt3;	
		g_u16RegParm[REG_PROTECT_OCDV1]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdv1;
		g_u16RegParm[REG_PROTECT_OCDT1]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdt1;
		g_u16RegParm[REG_PROTECT_OCDRV1]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdrv1;
		g_u16RegParm[REG_PROTECT_OCDRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdrt1;
		g_u16RegParm[REG_PROTECT_OCDV2]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdv2;
		g_u16RegParm[REG_PROTECT_OCDT2]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdt2;
		g_u16RegParm[REG_PROTECT_OCDRV2]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdrv2;
		g_u16RegParm[REG_PROTECT_OCDRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdrt2;	
		g_u16RegParm[REG_PROTECT_OCDV3]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdv3;
		g_u16RegParm[REG_PROTECT_OCDT3]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdt3;
		g_u16RegParm[REG_PROTECT_OCDRV3]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdrv3;
		g_u16RegParm[REG_PROTECT_OCDRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16ocdrt3;	
		g_u16RegParm[REG_PROTECT_OTC1]	= (uint16_t)g_stcParm.stcSwProtect.i16otc1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCT1]	= (uint16_t)g_stcParm.stcSwProtect.u16otct1;
		g_u16RegParm[REG_PROTECT_OTCR1]	= (uint16_t)g_stcParm.stcSwProtect.i16otcr1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16otcrt1;		
		g_u16RegParm[REG_PROTECT_OTC2]	= (uint16_t)g_stcParm.stcSwProtect.i16otc2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCT2]	= (uint16_t)g_stcParm.stcSwProtect.u16otct2;
		g_u16RegParm[REG_PROTECT_OTCR2]	= (uint16_t)g_stcParm.stcSwProtect.i16otcr2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16otcrt2;		
		g_u16RegParm[REG_PROTECT_OTC3]	= (uint16_t)g_stcParm.stcSwProtect.i16otc3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCT3]	= (uint16_t)g_stcParm.stcSwProtect.u16otct3;
		g_u16RegParm[REG_PROTECT_OTCR3]	= (uint16_t)g_stcParm.stcSwProtect.i16otcr3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16otcrt3;		
		g_u16RegParm[REG_PROTECT_UTC1]	= (uint16_t)g_stcParm.stcSwProtect.i16utc1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCT1]	= (uint16_t)g_stcParm.stcSwProtect.u16utct1;
		g_u16RegParm[REG_PROTECT_UTCR1]	= (uint16_t)g_stcParm.stcSwProtect.i16utcr1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16utcrt1;		
		g_u16RegParm[REG_PROTECT_UTC2]	= (uint16_t)g_stcParm.stcSwProtect.i16utc2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCT2]	= (uint16_t)g_stcParm.stcSwProtect.u16utct2;
		g_u16RegParm[REG_PROTECT_UTCR2]	= (uint16_t)g_stcParm.stcSwProtect.i16utcr2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16utcrt2;		
		g_u16RegParm[REG_PROTECT_UTC3]	= (uint16_t)g_stcParm.stcSwProtect.i16utc3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCT3]	= (uint16_t)g_stcParm.stcSwProtect.u16utct3;
		g_u16RegParm[REG_PROTECT_UTCR3]	= (uint16_t)g_stcParm.stcSwProtect.i16utcr3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16utcrt3;		
		g_u16RegParm[REG_PROTECT_OTD1]	= (uint16_t)g_stcParm.stcSwProtect.i16otd1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTDT1]	= (uint16_t)g_stcParm.stcSwProtect.u16otdt1;
		g_u16RegParm[REG_PROTECT_OTDR1]	= (uint16_t)g_stcParm.stcSwProtect.i16otdr1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTDRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16otdrt1;		
		g_u16RegParm[REG_PROTECT_OTD2]	= (uint16_t)g_stcParm.stcSwProtect.i16otd2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTDT2]	= (uint16_t)g_stcParm.stcSwProtect.u16otdt2;
		g_u16RegParm[REG_PROTECT_OTDR2]	= (uint16_t)g_stcParm.stcSwProtect.i16otdr2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTDRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16otdrt2;		
		g_u16RegParm[REG_PROTECT_OTD3]	= (uint16_t)g_stcParm.stcSwProtect.i16otd3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTDT3]	= (uint16_t)g_stcParm.stcSwProtect.u16otdt3;
		g_u16RegParm[REG_PROTECT_OTDR3]	= (uint16_t)g_stcParm.stcSwProtect.i16otdr3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTDRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16otdrt3;		
		g_u16RegParm[REG_PROTECT_UTD1]	= (uint16_t)g_stcParm.stcSwProtect.i16utd1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTDT1]	= (uint16_t)g_stcParm.stcSwProtect.u16utdt1;
		g_u16RegParm[REG_PROTECT_UTDR1]	= (uint16_t)g_stcParm.stcSwProtect.i16utdr1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTDRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16utdrt1;		
		g_u16RegParm[REG_PROTECT_UTD2]	= (uint16_t)g_stcParm.stcSwProtect.i16utd2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTDT2]	= (uint16_t)g_stcParm.stcSwProtect.u16utdt2;
		g_u16RegParm[REG_PROTECT_UTDR2]	= (uint16_t)g_stcParm.stcSwProtect.i16utdr2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTDRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16utdrt2;		
		g_u16RegParm[REG_PROTECT_UTD3]	= (uint16_t)g_stcParm.stcSwProtect.i16utd3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTDT3]	= (uint16_t)g_stcParm.stcSwProtect.u16utdt3;
		g_u16RegParm[REG_PROTECT_UTDR3]	= (uint16_t)g_stcParm.stcSwProtect.i16utdr3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTDRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16utdrt3;		
		g_u16RegParm[REG_PROTECT_OTCDM1]	= (uint16_t)g_stcParm.stcSwProtect.i16otcdm1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCDMT1]	= (uint16_t)g_stcParm.stcSwProtect.u16otcdmt1;
		g_u16RegParm[REG_PROTECT_OTCDMR1]	= (uint16_t)g_stcParm.stcSwProtect.i16otcdmr1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCDMRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16otcdmrt1;	
		g_u16RegParm[REG_PROTECT_OTCDM2]	= (uint16_t)g_stcParm.stcSwProtect.i16otcdm2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCDMT2]	= (uint16_t)g_stcParm.stcSwProtect.u16otcdmt2;
		g_u16RegParm[REG_PROTECT_OTCDMR2]	= (uint16_t)g_stcParm.stcSwProtect.i16otcdmr2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCDMRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16otcdmrt2;	
		g_u16RegParm[REG_PROTECT_OTCDM3]	= (uint16_t)g_stcParm.stcSwProtect.i16otcdm3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCDMT3]	= (uint16_t)g_stcParm.stcSwProtect.u16otcdmt3;
		g_u16RegParm[REG_PROTECT_OTCDMR3]	= (uint16_t)g_stcParm.stcSwProtect.i16otcdmr3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCDMRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16otcdmrt3;	
		g_u16RegParm[REG_PROTECT_UTCDM1]	= (uint16_t)g_stcParm.stcSwProtect.i16utcdm1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCDMT1]	= (uint16_t)g_stcParm.stcSwProtect.u16utcdmt1;
		g_u16RegParm[REG_PROTECT_UTCDMR1]	= (uint16_t)g_stcParm.stcSwProtect.i16utcdmr1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCDMRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16utcdmrt1;	
		g_u16RegParm[REG_PROTECT_UTCDM2]	= (uint16_t)g_stcParm.stcSwProtect.i16utcdm2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCDMT2]	= (uint16_t)g_stcParm.stcSwProtect.u16utcdmt2;
		g_u16RegParm[REG_PROTECT_UTCDMR2]	= (uint16_t)g_stcParm.stcSwProtect.i16utcdmr2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCDMRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16utcdmrt2;	
		g_u16RegParm[REG_PROTECT_UTCDM3]	= (uint16_t)g_stcParm.stcSwProtect.i16utcdm3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCDMT3]	= (uint16_t)g_stcParm.stcSwProtect.u16utcdmt3;
		g_u16RegParm[REG_PROTECT_UTCDMR3]	= (uint16_t)g_stcParm.stcSwProtect.i16utcdmr3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCDMRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16utcdmrt3;	
		g_u16RegParm[REG_PROTECT_OTAMB1]	= (uint16_t)g_stcParm.stcSwProtect.i16otamb1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTAMBT1]	= (uint16_t)g_stcParm.stcSwProtect.u16otambt1;
		g_u16RegParm[REG_PROTECT_OTAMBR1]	= (uint16_t)g_stcParm.stcSwProtect.i16otambr1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTAMBRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16otambrt1;			
		g_u16RegParm[REG_PROTECT_OTAMB2]	= (uint16_t)g_stcParm.stcSwProtect.i16otamb2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTAMBT2]	= (uint16_t)g_stcParm.stcSwProtect.u16otambt2;
		g_u16RegParm[REG_PROTECT_OTAMBR2]	= (uint16_t)g_stcParm.stcSwProtect.i16otambr2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTAMBRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16otambrt2;			
		g_u16RegParm[REG_PROTECT_OTAMB3]	= (uint16_t)g_stcParm.stcSwProtect.i16otamb3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTAMBT3]	= (uint16_t)g_stcParm.stcSwProtect.u16otambt3;
		g_u16RegParm[REG_PROTECT_OTAMBR3]	= (uint16_t)g_stcParm.stcSwProtect.i16otambr3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTAMBRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16otambrt3;	
		g_u16RegParm[REG_PROTECT_UTAMB1]	= (uint16_t)g_stcParm.stcSwProtect.i16utamb1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTAMBT1]	= (uint16_t)g_stcParm.stcSwProtect.u16utambt1;
		g_u16RegParm[REG_PROTECT_UTAMBR1]	= (uint16_t)g_stcParm.stcSwProtect.i16utambr1+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTAMBRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16utambrt1;			
		g_u16RegParm[REG_PROTECT_UTAMB2]	= (uint16_t)g_stcParm.stcSwProtect.i16utamb2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTAMBT2]	= (uint16_t)g_stcParm.stcSwProtect.u16utambt2;
		g_u16RegParm[REG_PROTECT_UTAMBR2]	= (uint16_t)g_stcParm.stcSwProtect.i16utambr2+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTAMBRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16utambrt2;			
		g_u16RegParm[REG_PROTECT_UTAMB3]	= (uint16_t)g_stcParm.stcSwProtect.i16utamb3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTAMBT3]	= (uint16_t)g_stcParm.stcSwProtect.u16utambt3;
		g_u16RegParm[REG_PROTECT_UTAMBR3]	= (uint16_t)g_stcParm.stcSwProtect.i16utambr3+ TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTAMBRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16utambrt3;		
		g_u16RegParm[REG_PROTECT_DIFFVOL1]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvol1;
		g_u16RegParm[REG_PROTECT_DIFFVOLT1]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolt1;
		g_u16RegParm[REG_PROTECT_DIFFVOLR1]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolr1;
		g_u16RegParm[REG_PROTECT_DIFFVOLRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolrt1;	
		g_u16RegParm[REG_PROTECT_DIFFVOL2]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvol2;
		g_u16RegParm[REG_PROTECT_DIFFVOLT2]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolt2;
		g_u16RegParm[REG_PROTECT_DIFFVOLR2]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolr2;
		g_u16RegParm[REG_PROTECT_DIFFVOLRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolrt2;	
		g_u16RegParm[REG_PROTECT_DIFFVOL3]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvol3;
		g_u16RegParm[REG_PROTECT_DIFFVOLT3]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolt3;
		g_u16RegParm[REG_PROTECT_DIFFVOLR3]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolr3;
		g_u16RegParm[REG_PROTECT_DIFFVOLRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16diffvolrt3;	
		g_u16RegParm[REG_PROTECT_TOV1]	= (uint16_t)g_stcParm.stcSwProtect.u16tov1;
		g_u16RegParm[REG_PROTECT_TOVT1]	= (uint16_t)g_stcParm.stcSwProtect.u16tovt1;
		g_u16RegParm[REG_PROTECT_TOVR1]	= (uint16_t)g_stcParm.stcSwProtect.u16tovr1;
		g_u16RegParm[REG_PROTECT_TOVRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16tovrt1;		
		g_u16RegParm[REG_PROTECT_TOV2]	= (uint16_t)g_stcParm.stcSwProtect.u16tov2;
		g_u16RegParm[REG_PROTECT_TOVT2]	= (uint16_t)g_stcParm.stcSwProtect.u16tovt2;
		g_u16RegParm[REG_PROTECT_TOVR2]	= (uint16_t)g_stcParm.stcSwProtect.u16tovr2;
		g_u16RegParm[REG_PROTECT_TOVRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16tovrt2;
		g_u16RegParm[REG_PROTECT_TOV3]	= (uint16_t)g_stcParm.stcSwProtect.u16tov3;
		g_u16RegParm[REG_PROTECT_TOVT3]	= (uint16_t)g_stcParm.stcSwProtect.u16tovt3;
		g_u16RegParm[REG_PROTECT_TOVR3]	= (uint16_t)g_stcParm.stcSwProtect.u16tovr3;
		g_u16RegParm[REG_PROTECT_TOVRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16tovrt3;
		g_u16RegParm[REG_PROTECT_TUV1]	= (uint16_t)g_stcParm.stcSwProtect.u16tuv1;
		g_u16RegParm[REG_PROTECT_TUVT1]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvt1;
		g_u16RegParm[REG_PROTECT_TUVR1]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvr1;
		g_u16RegParm[REG_PROTECT_TUVRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvrt1;		
		g_u16RegParm[REG_PROTECT_TUV2]	= (uint16_t)g_stcParm.stcSwProtect.u16tuv2;
		g_u16RegParm[REG_PROTECT_TUVT2]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvt2;
		g_u16RegParm[REG_PROTECT_TUVR2]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvr2;
		g_u16RegParm[REG_PROTECT_TUVRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvrt2;
		g_u16RegParm[REG_PROTECT_TUV3]	= (uint16_t)g_stcParm.stcSwProtect.u16tuv3;
		g_u16RegParm[REG_PROTECT_TUVT3]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvt3;
		g_u16RegParm[REG_PROTECT_TUVR3]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvr3;
		g_u16RegParm[REG_PROTECT_TUVRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16tuvrt3;		

		g_u16RegParm[REG_PROTECT_DIFFTEMP1]	= (uint16_t)g_stcParm.stcSwProtect.u16difftemp1;
		g_u16RegParm[REG_PROTECT_DIFFTEMPT1]	= (uint16_t)g_stcParm.stcSwProtect.u16difftempt1;
		g_u16RegParm[REG_PROTECT_DIFFTEMPR1]	= (uint16_t)g_stcParm.stcSwProtect.u16difftempr1;
		g_u16RegParm[REG_PROTECT_DIFFTEMPRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16difftemprt1;	
		g_u16RegParm[REG_PROTECT_DIFFTEMP2]	= (uint16_t)g_stcParm.stcSwProtect.u16difftemp2;
		g_u16RegParm[REG_PROTECT_DIFFTEMPT2]	= (uint16_t)g_stcParm.stcSwProtect.u16difftempt2;
		g_u16RegParm[REG_PROTECT_DIFFTEMPR2]	= (uint16_t)g_stcParm.stcSwProtect.u16difftempr2;
		g_u16RegParm[REG_PROTECT_DIFFTEMPRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16difftemprt2;		
		g_u16RegParm[REG_PROTECT_DIFFTEMP3]	= (uint16_t)g_stcParm.stcSwProtect.u16difftemp3;
		g_u16RegParm[REG_PROTECT_DIFFTEMPT3]	= (uint16_t)g_stcParm.stcSwProtect.u16difftempt3;
		g_u16RegParm[REG_PROTECT_DIFFTEMPR3]	= (uint16_t)g_stcParm.stcSwProtect.u16difftempr3;
		g_u16RegParm[REG_PROTECT_DIFFTEMPRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16difftemprt3;	
		g_u16RegParm[REG_PROTECT_SOCLOW1]	= (uint16_t)g_stcParm.stcSwProtect.u16soclow1;
		g_u16RegParm[REG_PROTECT_SOCLOWT1]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowt1;
		g_u16RegParm[REG_PROTECT_SOCLOWR1]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowr1;
		g_u16RegParm[REG_PROTECT_SOCLOWRT1]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowrt1;
		g_u16RegParm[REG_PROTECT_SOCLOW2]	= (uint16_t)g_stcParm.stcSwProtect.u16soclow2;
		g_u16RegParm[REG_PROTECT_SOCLOWT2]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowt2;
		g_u16RegParm[REG_PROTECT_SOCLOWR2]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowr2;
		g_u16RegParm[REG_PROTECT_SOCLOWRT2]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowrt2;		
		g_u16RegParm[REG_PROTECT_SOCLOW3]	= (uint16_t)g_stcParm.stcSwProtect.u16soclow3;
		g_u16RegParm[REG_PROTECT_SOCLOWT3]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowt3;
		g_u16RegParm[REG_PROTECT_SOCLOWR3]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowr3;
		g_u16RegParm[REG_PROTECT_SOCLOWRT3]	= (uint16_t)g_stcParm.stcSwProtect.u16soclowrt3;		
		
		g_u16RegParm[REG_PROTECT_OV]	= (uint16_t)g_stcParm.stcHwProtect.u16ov;
		g_u16RegParm[REG_PROTECT_OVT]	= (uint16_t)g_stcParm.stcHwProtect.u16ovt;
		g_u16RegParm[REG_PROTECT_OVR]	= (uint16_t)g_stcParm.stcHwProtect.u16ovr;
		g_u16RegParm[REG_PROTECT_OVRT]	= (uint16_t)g_stcParm.stcHwProtect.u16ovrt;				
		g_u16RegParm[REG_PROTECT_UV]	= (uint16_t)g_stcParm.stcHwProtect.u16uv;
		g_u16RegParm[REG_PROTECT_UVT]	= (uint16_t)g_stcParm.stcHwProtect.u16uvt;
		g_u16RegParm[REG_PROTECT_UVR]	= (uint16_t)g_stcParm.stcHwProtect.u16uvr;
		g_u16RegParm[REG_PROTECT_UVRT]	= (uint16_t)g_stcParm.stcHwProtect.u16uvrt;	
		g_u16RegParm[REG_PROTECT_OCCV]	= (uint16_t)g_stcParm.stcHwProtect.u16occv;
		g_u16RegParm[REG_PROTECT_OCCT]	= (uint16_t)g_stcParm.stcHwProtect.u16occt;
		g_u16RegParm[REG_PROTECT_OCCRV]	= (uint16_t)g_stcParm.stcHwProtect.u16occrv;
		g_u16RegParm[REG_PROTECT_OCCRT]	= (uint16_t)g_stcParm.stcHwProtect.u16occrt;	
		g_u16RegParm[REG_PROTECT_OCDV]	= (uint16_t)g_stcParm.stcHwProtect.u16ocdv;
		g_u16RegParm[REG_PROTECT_OCDT]	= (uint16_t)g_stcParm.stcHwProtect.u16ocdt;
		g_u16RegParm[REG_PROTECT_OCDRV]	= (uint16_t)g_stcParm.stcHwProtect.u16ocdrv;
		g_u16RegParm[REG_PROTECT_OCDRT]	= (uint16_t)g_stcParm.stcHwProtect.u16ocdrt;
		g_u16RegParm[REG_PROTECT_SCV]	= (uint16_t)g_stcParm.stcHwProtect.u16scv;
		g_u16RegParm[REG_PROTECT_SCT]	= (uint16_t)g_stcParm.stcHwProtect.u16sct;	
		g_u16RegParm[REG_PROTECT_OTC]	= (uint16_t)g_stcParm.stcHwProtect.i16otc + TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCT]	= (uint16_t)g_stcParm.stcHwProtect.u16otct;
		g_u16RegParm[REG_PROTECT_OTCR]	= (uint16_t)g_stcParm.stcHwProtect.i16otcr + TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTCRT]	= (uint16_t)g_stcParm.stcHwProtect.u16otcrt;	
		g_u16RegParm[REG_PROTECT_UTC]	= (uint16_t)g_stcParm.stcHwProtect.i16utc + TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCT]	= (uint16_t)g_stcParm.stcHwProtect.u16utct;
		g_u16RegParm[REG_PROTECT_UTCR]	= (uint16_t)g_stcParm.stcHwProtect.i16utcr + TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTCRT]	= (uint16_t)g_stcParm.stcHwProtect.u16utcrt;
		g_u16RegParm[REG_PROTECT_OTD]	= (uint16_t)g_stcParm.stcHwProtect.i16otd + TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTDT]	= (uint16_t)g_stcParm.stcHwProtect.u16otdt;
		g_u16RegParm[REG_PROTECT_OTDR]	= (uint16_t)g_stcParm.stcHwProtect.i16otdr + TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_OTDRT]	= (uint16_t)g_stcParm.stcHwProtect.u16otdrt;	
		g_u16RegParm[REG_PROTECT_UTD]	= (uint16_t)g_stcParm.stcHwProtect.i16utd + TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTDT]	= (uint16_t)g_stcParm.stcHwProtect.u16utdt;
		g_u16RegParm[REG_PROTECT_UTDR]	= (uint16_t)g_stcParm.stcHwProtect.i16utdr + TEMP_OFFSET;
		g_u16RegParm[REG_PROTECT_UTDRT]	= (uint16_t)g_stcParm.stcHwProtect.u16utdrt;

		for (u8i = 0; u8i < 8; u8i++)
		{
				g_u16RegParm[REG_CAL_TEMP + u8i] = (uint16_t)g_stcParm.stcCal.i16temperature[u8i];
		}

		for (u8i = 0; u8i < 32; u8i++)
		{
				g_u16RegParm[REG_CAL_VOL + u8i] = (uint16_t)g_stcParm.stcCal.i16voltage[u8i];
		}
		
		g_u16RegParm[REG_CAL_ZEROCUR]	= (uint16_t)g_stcParm.stcConfig.i16currZeroOffSetADVal;		
		g_u16RegParm[REG_CAL_RATCHG]	= (uint16_t)g_stcParm.stcConfig.u16currRatioCharge;
		g_u16RegParm[REG_CAL_RATDSG]	= (uint16_t)g_stcParm.stcConfig.u16currRatioDisCharge;		
		
}

/**
 * @brief  write reg parm refresh
 * @param  
 * @return 
 * @note   
 */
void srv_parm_writeRegRefresh(void)
{
    uint8_t u8Temp[40];
	  uint8_t u8i;
	
		memset((void *) u8Temp, 0x20, 32);
	  for (u8i = 0; u8i < 16; u8i++)
		{
				u8Temp[2*u8i] = g_u16RegParm[REG_BASIC_DEVIC_ID+u8i] >> 8;
				u8Temp[2*u8i+1] = g_u16RegParm[REG_BASIC_DEVIC_ID+u8i] >> 0;
		}			
	  memcpy(g_stcParm.stcConfig.cdevSn,&u8Temp[0],32);
	
		memset((void *) u8Temp, 0x20, 20);
	  for (u8i = 0; u8i < 10; u8i++)
		{
				u8Temp[2*u8i] = g_u16RegParm[REG_BASIC_FACTORY_ID+u8i] >> 8;
				u8Temp[2*u8i+1] = g_u16RegParm[REG_BASIC_FACTORY_ID+u8i] >> 0;
		}			
	  memcpy(g_stcParm.stcConfig.cfactorySn,&u8Temp[0],20);	
	
		memset((void *) u8Temp, 0x20, 20);
	  for (u8i = 0; u8i < 10; u8i++)
		{
				u8Temp[2*u8i] = g_u16RegParm[REG_BASIC_PROJECT_CODE+u8i] >> 8;
				u8Temp[2*u8i+1] = g_u16RegParm[REG_BASIC_PROJECT_CODE+u8i] >> 0;
		}		
	  memcpy(g_stcParm.stcConfig.cprojectSn,&u8Temp[0],20);	
	
		memset((void *) u8Temp, 0x20, 20);
	  for (u8i = 0; u8i < 10; u8i++)
		{
				u8Temp[2*u8i] = g_u16RegParm[REG_BASIC_BATTERY_NUM+u8i] >> 8;
				u8Temp[2*u8i+1] = g_u16RegParm[REG_BASIC_BATTERY_NUM+u8i] >> 0;
		}				
	  memcpy(g_stcParm.stcConfig.cbatterySn,&u8Temp[0],20);	

		memset((void *) u8Temp, 0x20, 20);
	  for (u8i = 0; u8i < 10; u8i++)
		{
				u8Temp[2*u8i] = g_u16RegParm[REG_BASIC_ICCID_NUM+u8i] >> 8;
				u8Temp[2*u8i+1] = g_u16RegParm[REG_BASIC_ICCID_NUM+u8i] >> 0;
		}		
	  memcpy(g_stcParm.stcConfig.ciccidSn,&u8Temp[0],20);	
		
		memset((void *) u8Temp, 0x20, 20);
	  for (u8i = 0; u8i < 10; u8i++)
		{
				u8Temp[2*u8i] = g_u16RegParm[REG_BASIC_IMEI_NUM+u8i] >> 8;
				u8Temp[2*u8i+1] = g_u16RegParm[REG_BASIC_IMEI_NUM+u8i] >> 0;
		}				
	  memcpy(g_stcParm.stcConfig.cimeiSn,&u8Temp[0],20);	
		
		memset((void *) u8Temp, 0x20, 30);
	  for (u8i = 0; u8i < 15; u8i++)
		{
				u8Temp[2*u8i] = g_u16RegParm[REG_BASIC_PASSWORD+u8i] >> 8;
				u8Temp[2*u8i+1] = g_u16RegParm[REG_BASIC_PASSWORD+u8i] >> 0;
		}			
	  memcpy(g_stcParm.stcConfig.cpasswordSn,&u8Temp[0],30);	
		
	  //drv_rtc_getTime(&u8Temp[0]);
		//memcpy(&g_u16RegParm[REG_BASIC_RTC_TIME],u8Temp,6);	

		g_stcParm.stcConfig.u8curSw = g_u16RegParm[REG_CONFIG_CURSW];	
		g_stcParm.stcConfig.u16curThr = g_u16RegParm[REG_CONFIG_CURTHR];	
		g_stcParm.stcConfig.u16curTime = g_u16RegParm[REG_CONFIG_CURTIME];	
		g_stcParm.stcConfig.u16cycleCount = g_u16RegParm[REG_CONFIG_CYCLECOUNT];			
		g_stcParm.stcConfig.u16perChgVol = g_u16RegParm[REG_CONFIG_PERCHGVOL];			
		g_stcParm.stcConfig.u8afeType = g_u16RegParm[REG_CONFIG_AFETYPE];	
		g_stcParm.stcConfig.u8invType = g_u16RegParm[REG_CONFIG_INVTYPE];	
		g_stcParm.stcConfig.u8batteryType = g_u16RegParm[REG_CONFIG_BATTERYTYPE];	
		g_stcParm.stcConfig.u8cellS = g_u16RegParm[REG_CONFIG_CELLS];	
		g_stcParm.stcConfig.u8cellP = g_u16RegParm[REG_CONFIG_CELLP];
		g_stcParm.stcConfig.u8chgCabType = g_u16RegParm[REG_CONFIG_CHGCAB];		
		g_stcParm.stcConfig.u8commuAddr = g_u16RegParm[REG_CONFIG_COMMUADDR];
		g_stcParm.stcConfig.u16forbidChgVol = g_u16RegParm[REG_CONFIG_FORBIDCHGVOL];
		g_stcParm.stcConfig.u16maxChgCur = g_u16RegParm[REG_CONFIG_MAXCHGCUR];
		g_stcParm.stcConfig.u8forbidBalHightTempThr = g_u16RegParm[REG_CONFIG_FORBIDBALHIGHTTEMPTHR] - TEMP_OFFSET;
		g_stcParm.stcConfig.u8forbidBalLowTempThr = g_u16RegParm[REG_CONFIG_FORBIDBALLOWTEMPTHR] - TEMP_OFFSET;	
		g_stcParm.stcConfig.u16fullChgVol = g_u16RegParm[REG_CONFIG_FULLCHGVOL];	
		g_stcParm.stcConfig.u16fullChgCur = g_u16RegParm[REG_CONFIG_FULLCHGCUR];
		g_stcParm.stcConfig.u16fullChgDuration = g_u16RegParm[REG_CONFIG_FULLCHGDURATION];
		g_stcParm.stcConfig.u32modFunc = g_u16RegParm[REG_CONFIG_MODFUNC];
		g_stcParm.stcConfig.u32rank2Func = (((uint32_t)g_u16RegParm[REG_CONFIG_RANK2FUNC + 1] << 16) | ((uint32_t)g_u16RegParm[REG_CONFIG_RANK2FUNC]));				
		g_stcParm.stcConfig.u32rank1Func = (((uint32_t)g_u16RegParm[REG_CONFIG_RANK1FUNC + 1] << 16) | ((uint32_t)g_u16RegParm[REG_CONFIG_RANK1FUNC]));		
			
		g_stcParm.stcConfig.u16samplingResistor = g_u16RegParm[REG_CONFIG_SAMPRESISTOR];	
		g_stcParm.stcConfig.u16dispSoc = g_u16RegParm[REG_CONFIG_DISPSOC];
		g_stcParm.stcConfig.u16trueSoc = g_u16RegParm[REG_CONFIG_TRUESOC];			
		g_stcParm.stcConfig.u16socInterval = g_u16RegParm[REG_CONFIG_SOCINTERVAL];	
		g_stcParm.stcConfig.u8soh = g_u16RegParm[REG_CONFIG_SOH];			
		g_stcParm.stcConfig.u16designVol = g_u16RegParm[REG_CONFIG_DESIGNVOL];
		
		g_stcParm.stcConfig.u32designCap = (((uint32_t)g_u16RegParm[REG_CONFIG_DESIGNCAP] << 16) | ((uint32_t)g_u16RegParm[REG_CONFIG_DESIGNCAP +1]));		
		g_stcParm.stcConfig.u32fullChgCap = (((uint32_t)g_u16RegParm[REG_CONFIG_FULLCHGCAP] << 16) | ((uint32_t)g_u16RegParm[REG_CONFIG_FULLCHGCAP +1]));	
		g_stcParm.stcConfig.u32remainCap = (((uint32_t)g_u16RegParm[REG_CONFIG_REMAINCAP] << 16) | ((uint32_t)g_u16RegParm[REG_CONFIG_REMAINCAP +1]));	
		g_stcParm.stcConfig.u32accChgCap = (((uint32_t)g_u16RegParm[REG_CONFIG_ACCCHGCAP] << 16) | ((uint32_t)g_u16RegParm[REG_CONFIG_ACCCHGCAP +1]));	
		g_stcParm.stcConfig.u32accDsgCap = (((uint32_t)g_u16RegParm[REG_CONFIG_ACCDSGCAP] << 16) | ((uint32_t)g_u16RegParm[REG_CONFIG_ACCDSGCAP +1]));
		
		g_stcParm.stcSwProtect.u16ov1 = g_u16RegParm[REG_PROTECT_OV1];
		g_stcParm.stcSwProtect.u16ovt1 = g_u16RegParm[REG_PROTECT_OVT1];
		g_stcParm.stcSwProtect.u16ovr1 = g_u16RegParm[REG_PROTECT_OVR1];
		g_stcParm.stcSwProtect.u16ovrt1 = g_u16RegParm[REG_PROTECT_OVRT1];		
		g_stcParm.stcSwProtect.u16ov2 = g_u16RegParm[REG_PROTECT_OV2];
		g_stcParm.stcSwProtect.u16ovt2 = g_u16RegParm[REG_PROTECT_OVT2];
		g_stcParm.stcSwProtect.u16ovr2 = g_u16RegParm[REG_PROTECT_OVR2];
		g_stcParm.stcSwProtect.u16ovrt2 = g_u16RegParm[REG_PROTECT_OVRT2];
		g_stcParm.stcSwProtect.u16ov3 = g_u16RegParm[REG_PROTECT_OV3];
		g_stcParm.stcSwProtect.u16ovt3 = g_u16RegParm[REG_PROTECT_OVT3];
		g_stcParm.stcSwProtect.u16ovr3 = g_u16RegParm[REG_PROTECT_OVR3];
		g_stcParm.stcSwProtect.u16ovrt3 = g_u16RegParm[REG_PROTECT_OVRT3];
		g_stcParm.stcSwProtect.u16uv1 = g_u16RegParm[REG_PROTECT_UV1];
		g_stcParm.stcSwProtect.u16uvt1 = g_u16RegParm[REG_PROTECT_UVT1];
		g_stcParm.stcSwProtect.u16uvr1 = g_u16RegParm[REG_PROTECT_UVR1];
		g_stcParm.stcSwProtect.u16uvrt1 = g_u16RegParm[REG_PROTECT_UVRT1];		
		g_stcParm.stcSwProtect.u16uv2 = g_u16RegParm[REG_PROTECT_UV2];
		g_stcParm.stcSwProtect.u16uvt2 = g_u16RegParm[REG_PROTECT_UVT2];
		g_stcParm.stcSwProtect.u16uvr2 = g_u16RegParm[REG_PROTECT_UVR2];
		g_stcParm.stcSwProtect.u16uvrt2 = g_u16RegParm[REG_PROTECT_UVRT2];
		g_stcParm.stcSwProtect.u16uv3 = g_u16RegParm[REG_PROTECT_UV3];
		g_stcParm.stcSwProtect.u16uvt3 = g_u16RegParm[REG_PROTECT_UVT3];
		g_stcParm.stcSwProtect.u16uvr3 = g_u16RegParm[REG_PROTECT_UVR3];
		g_stcParm.stcSwProtect.u16uvrt3 = g_u16RegParm[REG_PROTECT_UVRT3];	
		g_stcParm.stcSwProtect.u16balOpenV = g_u16RegParm[REG_PROTECT_BALOPENV];
		g_stcParm.stcSwProtect.u16balOpenD = g_u16RegParm[REG_PROTECT_BALOPEND];
		g_stcParm.stcSwProtect.u16balOpenT = g_u16RegParm[REG_PROTECT_BALOPENT];
		g_stcParm.stcSwProtect.u16balCloseV = g_u16RegParm[REG_PROTECT_BALCLOSEV];
		g_stcParm.stcSwProtect.u16balCloseD = g_u16RegParm[REG_PROTECT_BALCLOSED];
		g_stcParm.stcSwProtect.u16balCloseT = g_u16RegParm[REG_PROTECT_BALCLOSET];		
		g_stcParm.stcSwProtect.u16occv1 = g_u16RegParm[REG_PROTECT_OCCV1];
		g_stcParm.stcSwProtect.u16occt1 = g_u16RegParm[REG_PROTECT_OCCT1];
		g_stcParm.stcSwProtect.u16occrv1 = g_u16RegParm[REG_PROTECT_OCCRV1];
		g_stcParm.stcSwProtect.u16occrt1 = g_u16RegParm[REG_PROTECT_OCCRT1];
		g_stcParm.stcSwProtect.u16occv2 = g_u16RegParm[REG_PROTECT_OCCV2];
		g_stcParm.stcSwProtect.u16occt2 = g_u16RegParm[REG_PROTECT_OCCT2];
		g_stcParm.stcSwProtect.u16occrv2 = g_u16RegParm[REG_PROTECT_OCCRV2];
		g_stcParm.stcSwProtect.u16occrt2 = g_u16RegParm[REG_PROTECT_OCCRT2];	
		g_stcParm.stcSwProtect.u16occv3 = g_u16RegParm[REG_PROTECT_OCCV3];
		g_stcParm.stcSwProtect.u16occt3 = g_u16RegParm[REG_PROTECT_OCCT3];
		g_stcParm.stcSwProtect.u16occrv3 = g_u16RegParm[REG_PROTECT_OCCRV3];
		g_stcParm.stcSwProtect.u16occrt3 = g_u16RegParm[REG_PROTECT_OCCRT3];	
		g_stcParm.stcSwProtect.u16ocdv1 = g_u16RegParm[REG_PROTECT_OCDV1];
		g_stcParm.stcSwProtect.u16ocdt1 = g_u16RegParm[REG_PROTECT_OCDT1];
		g_stcParm.stcSwProtect.u16ocdrv1 = g_u16RegParm[REG_PROTECT_OCDRV1];
		g_stcParm.stcSwProtect.u16ocdrt1 = g_u16RegParm[REG_PROTECT_OCDRT1];
		g_stcParm.stcSwProtect.u16ocdv2 = g_u16RegParm[REG_PROTECT_OCDV2];
		g_stcParm.stcSwProtect.u16ocdt2 = g_u16RegParm[REG_PROTECT_OCDT2];
		g_stcParm.stcSwProtect.u16ocdrv2 = g_u16RegParm[REG_PROTECT_OCDRV2];
		g_stcParm.stcSwProtect.u16ocdrt2 = g_u16RegParm[REG_PROTECT_OCDRT2];	
		g_stcParm.stcSwProtect.u16ocdv3 = g_u16RegParm[REG_PROTECT_OCDV3];
		g_stcParm.stcSwProtect.u16ocdt3 = g_u16RegParm[REG_PROTECT_OCDT3];
		g_stcParm.stcSwProtect.u16ocdrv3 = g_u16RegParm[REG_PROTECT_OCDRV3];
		g_stcParm.stcSwProtect.u16ocdrt3 = g_u16RegParm[REG_PROTECT_OCDRT3];	
		g_stcParm.stcSwProtect.i16otc1 = g_u16RegParm[REG_PROTECT_OTC1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otct1 = g_u16RegParm[REG_PROTECT_OTCT1];
		g_stcParm.stcSwProtect.i16otcr1 = g_u16RegParm[REG_PROTECT_OTCR1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcrt1 = g_u16RegParm[REG_PROTECT_OTCRT1];		
		g_stcParm.stcSwProtect.i16otc2 = g_u16RegParm[REG_PROTECT_OTC2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otct2 = g_u16RegParm[REG_PROTECT_OTCT2];
		g_stcParm.stcSwProtect.i16otcr2 = g_u16RegParm[REG_PROTECT_OTCR2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcrt2 = g_u16RegParm[REG_PROTECT_OTCRT2];		
		g_stcParm.stcSwProtect.i16otc3 = g_u16RegParm[REG_PROTECT_OTC3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otct3 = g_u16RegParm[REG_PROTECT_OTCT3];
		g_stcParm.stcSwProtect.i16otcr3 = g_u16RegParm[REG_PROTECT_OTCR3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcrt3 = g_u16RegParm[REG_PROTECT_OTCRT3];		
		g_stcParm.stcSwProtect.i16utc1 = g_u16RegParm[REG_PROTECT_UTC1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utct1 = g_u16RegParm[REG_PROTECT_UTCT1];
		g_stcParm.stcSwProtect.i16utcr1 = g_u16RegParm[REG_PROTECT_UTCR1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcrt1 = g_u16RegParm[REG_PROTECT_UTCRT1];		
		g_stcParm.stcSwProtect.i16utc2 = g_u16RegParm[REG_PROTECT_UTC2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utct2 = g_u16RegParm[REG_PROTECT_UTCT2];
		g_stcParm.stcSwProtect.i16utcr2 = g_u16RegParm[REG_PROTECT_UTCR2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcrt2 = g_u16RegParm[REG_PROTECT_UTCRT2];		
		g_stcParm.stcSwProtect.i16utc3 = g_u16RegParm[REG_PROTECT_UTC3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utct3 = g_u16RegParm[REG_PROTECT_UTCT3];
		g_stcParm.stcSwProtect.i16utcr3 = g_u16RegParm[REG_PROTECT_UTCR3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcrt3 = g_u16RegParm[REG_PROTECT_UTCRT3];		
		g_stcParm.stcSwProtect.i16otd1 = g_u16RegParm[REG_PROTECT_OTD1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otdt1 = g_u16RegParm[REG_PROTECT_OTDT1];
		g_stcParm.stcSwProtect.i16otdr1 = g_u16RegParm[REG_PROTECT_OTDR1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otdrt1 = g_u16RegParm[REG_PROTECT_OTDRT1];		
		g_stcParm.stcSwProtect.i16otd2 = g_u16RegParm[REG_PROTECT_OTD2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otdt2 = g_u16RegParm[REG_PROTECT_OTDT2];
		g_stcParm.stcSwProtect.i16otdr2 = g_u16RegParm[REG_PROTECT_OTDR2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otdrt2 = g_u16RegParm[REG_PROTECT_OTDRT2];		
		g_stcParm.stcSwProtect.i16otd3 = g_u16RegParm[REG_PROTECT_OTD3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otdt3 = g_u16RegParm[REG_PROTECT_OTDT3];
		g_stcParm.stcSwProtect.i16otdr3 = g_u16RegParm[REG_PROTECT_OTDR3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otdrt3 = g_u16RegParm[REG_PROTECT_OTDRT3];		
		g_stcParm.stcSwProtect.i16utd1 = g_u16RegParm[REG_PROTECT_UTD1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utdt1 = g_u16RegParm[REG_PROTECT_UTDT1];
		g_stcParm.stcSwProtect.i16utdr1 = g_u16RegParm[REG_PROTECT_UTDR1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utdrt1 = g_u16RegParm[REG_PROTECT_UTDRT1];		
		g_stcParm.stcSwProtect.i16utd2 = g_u16RegParm[REG_PROTECT_UTD2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utdt2 = g_u16RegParm[REG_PROTECT_UTDT2];
		g_stcParm.stcSwProtect.i16utdr2 = g_u16RegParm[REG_PROTECT_UTDR2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utdrt2 = g_u16RegParm[REG_PROTECT_UTDRT2];		
		g_stcParm.stcSwProtect.i16utd3 = g_u16RegParm[REG_PROTECT_UTD3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utdt3 = g_u16RegParm[REG_PROTECT_UTDT3];
		g_stcParm.stcSwProtect.i16utdr3 = g_u16RegParm[REG_PROTECT_UTDR3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utdrt3 = g_u16RegParm[REG_PROTECT_UTDRT3];		
		g_stcParm.stcSwProtect.i16otcdm1 = g_u16RegParm[REG_PROTECT_OTCDM1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcdmt1 = g_u16RegParm[REG_PROTECT_OTCDMT1];
		g_stcParm.stcSwProtect.i16otcdmr1 = g_u16RegParm[REG_PROTECT_OTCDMR1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcdmrt1 = g_u16RegParm[REG_PROTECT_OTCDMRT1];	
		g_stcParm.stcSwProtect.i16otcdm2 = g_u16RegParm[REG_PROTECT_OTCDM2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcdmt2 = g_u16RegParm[REG_PROTECT_OTCDMT2];
		g_stcParm.stcSwProtect.i16otcdmr2 = g_u16RegParm[REG_PROTECT_OTCDMR2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcdmrt2 = g_u16RegParm[REG_PROTECT_OTCDMRT2];			
		g_stcParm.stcSwProtect.i16otcdm3 = g_u16RegParm[REG_PROTECT_OTCDM3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcdmt3 = g_u16RegParm[REG_PROTECT_OTCDMT3];
		g_stcParm.stcSwProtect.i16otcdmr3 = g_u16RegParm[REG_PROTECT_OTCDMR3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otcdmrt3 = g_u16RegParm[REG_PROTECT_OTCDMRT3];	
		g_stcParm.stcSwProtect.i16utcdm1 = g_u16RegParm[REG_PROTECT_UTCDM1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcdmt1 = g_u16RegParm[REG_PROTECT_UTCDMT1];
		g_stcParm.stcSwProtect.i16utcdmr1 = g_u16RegParm[REG_PROTECT_UTCDMR1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcdmrt1 = g_u16RegParm[REG_PROTECT_UTCDMRT1];	
		g_stcParm.stcSwProtect.i16utcdm2 = g_u16RegParm[REG_PROTECT_UTCDM2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcdmt2 = g_u16RegParm[REG_PROTECT_UTCDMT2];
		g_stcParm.stcSwProtect.i16utcdmr2 = g_u16RegParm[REG_PROTECT_UTCDMR2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcdmrt2 = g_u16RegParm[REG_PROTECT_UTCDMRT2];
		g_stcParm.stcSwProtect.i16utcdm3 = g_u16RegParm[REG_PROTECT_UTCDM3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcdmt3 = g_u16RegParm[REG_PROTECT_UTCDMT3];
		g_stcParm.stcSwProtect.i16utcdmr3 = g_u16RegParm[REG_PROTECT_UTCDMR3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utcdmrt3 = g_u16RegParm[REG_PROTECT_UTCDMRT3];
		g_stcParm.stcSwProtect.i16otamb1 = g_u16RegParm[REG_PROTECT_OTAMB1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otambt1 = g_u16RegParm[REG_PROTECT_OTAMBT1];
		g_stcParm.stcSwProtect.i16otambr1 = g_u16RegParm[REG_PROTECT_OTAMBR1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otambrt1 = g_u16RegParm[REG_PROTECT_OTAMBRT1];			
		g_stcParm.stcSwProtect.i16otamb2 = g_u16RegParm[REG_PROTECT_OTAMB2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otambt2 = g_u16RegParm[REG_PROTECT_OTAMBT2];
		g_stcParm.stcSwProtect.i16otambr2 = g_u16RegParm[REG_PROTECT_OTAMBR2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otambrt2 = g_u16RegParm[REG_PROTECT_OTAMBRT2];	
		g_stcParm.stcSwProtect.i16otamb3 = g_u16RegParm[REG_PROTECT_OTAMB3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otambt3 = g_u16RegParm[REG_PROTECT_OTAMBT3];
		g_stcParm.stcSwProtect.i16otambr3 = g_u16RegParm[REG_PROTECT_OTAMBR3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16otambrt3 = g_u16RegParm[REG_PROTECT_OTAMBRT3];			
		g_stcParm.stcSwProtect.i16utamb1 = g_u16RegParm[REG_PROTECT_UTAMB1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utambt1 = g_u16RegParm[REG_PROTECT_UTAMBT1];
		g_stcParm.stcSwProtect.i16utambr1 = g_u16RegParm[REG_PROTECT_UTAMBR1] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utambrt1 = g_u16RegParm[REG_PROTECT_UTAMBRT1];			
		g_stcParm.stcSwProtect.i16utamb2 = g_u16RegParm[REG_PROTECT_UTAMB2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utambt2 = g_u16RegParm[REG_PROTECT_UTAMBT2];
		g_stcParm.stcSwProtect.i16utambr2 = g_u16RegParm[REG_PROTECT_UTAMBR2] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utambrt2 = g_u16RegParm[REG_PROTECT_UTAMBRT2];	
		g_stcParm.stcSwProtect.i16utamb3 = g_u16RegParm[REG_PROTECT_UTAMB3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utambt3 = g_u16RegParm[REG_PROTECT_UTAMBT3];
		g_stcParm.stcSwProtect.i16utambr3 = g_u16RegParm[REG_PROTECT_UTAMBR3] - TEMP_OFFSET;
		g_stcParm.stcSwProtect.u16utambrt3 = g_u16RegParm[REG_PROTECT_UTAMBRT3];	
		g_stcParm.stcSwProtect.u16diffvol1 = g_u16RegParm[REG_PROTECT_DIFFVOL1];
		g_stcParm.stcSwProtect.u16diffvolt1 = g_u16RegParm[REG_PROTECT_DIFFVOLT1];
		g_stcParm.stcSwProtect.u16diffvolr1 = g_u16RegParm[REG_PROTECT_DIFFVOLR1];
		g_stcParm.stcSwProtect.u16diffvolrt1 = g_u16RegParm[REG_PROTECT_DIFFVOLRT1];	
		g_stcParm.stcSwProtect.u16diffvol2 = g_u16RegParm[REG_PROTECT_DIFFVOL2];
		g_stcParm.stcSwProtect.u16diffvolt2 = g_u16RegParm[REG_PROTECT_DIFFVOLT2];
		g_stcParm.stcSwProtect.u16diffvolr2 = g_u16RegParm[REG_PROTECT_DIFFVOLR2];
		g_stcParm.stcSwProtect.u16diffvolrt2 = g_u16RegParm[REG_PROTECT_DIFFVOLRT2];		
		g_stcParm.stcSwProtect.u16diffvol3 = g_u16RegParm[REG_PROTECT_DIFFVOL3];
		g_stcParm.stcSwProtect.u16diffvolt3 = g_u16RegParm[REG_PROTECT_DIFFVOLT3];
		g_stcParm.stcSwProtect.u16diffvolr3 = g_u16RegParm[REG_PROTECT_DIFFVOLR3];
		g_stcParm.stcSwProtect.u16diffvolrt3 = g_u16RegParm[REG_PROTECT_DIFFVOLRT3];
		g_stcParm.stcSwProtect.u16tov1 = g_u16RegParm[REG_PROTECT_TOV1];
		g_stcParm.stcSwProtect.u16tovt1 = g_u16RegParm[REG_PROTECT_TOVT1];
		g_stcParm.stcSwProtect.u16tovr1 = g_u16RegParm[REG_PROTECT_TOVR1];
		g_stcParm.stcSwProtect.u16tovrt1 = g_u16RegParm[REG_PROTECT_TOVRT1];	
		g_stcParm.stcSwProtect.u16tov2 = g_u16RegParm[REG_PROTECT_TOV2];
		g_stcParm.stcSwProtect.u16tovt2 = g_u16RegParm[REG_PROTECT_TOVT2];
		g_stcParm.stcSwProtect.u16tovr2 = g_u16RegParm[REG_PROTECT_TOVR2];
		g_stcParm.stcSwProtect.u16tovrt2 = g_u16RegParm[REG_PROTECT_TOVRT2];	
		g_stcParm.stcSwProtect.u16tov3 = g_u16RegParm[REG_PROTECT_TOV3];
		g_stcParm.stcSwProtect.u16tovt3 = g_u16RegParm[REG_PROTECT_TOVT3];
		g_stcParm.stcSwProtect.u16tovr3 = g_u16RegParm[REG_PROTECT_TOVR3];
		g_stcParm.stcSwProtect.u16tovrt3 = g_u16RegParm[REG_PROTECT_TOVRT3];			
		g_stcParm.stcSwProtect.u16tuv1 = g_u16RegParm[REG_PROTECT_TUV1];
		g_stcParm.stcSwProtect.u16tuvt1 = g_u16RegParm[REG_PROTECT_TUVT1];
		g_stcParm.stcSwProtect.u16tuvr1 = g_u16RegParm[REG_PROTECT_TUVR1];
		g_stcParm.stcSwProtect.u16tuvrt1 = g_u16RegParm[REG_PROTECT_TUVRT1];		
		g_stcParm.stcSwProtect.u16tuv2 = g_u16RegParm[REG_PROTECT_TUV2];
		g_stcParm.stcSwProtect.u16tuvt2 = g_u16RegParm[REG_PROTECT_TUVT2];
		g_stcParm.stcSwProtect.u16tuvr2 = g_u16RegParm[REG_PROTECT_TUVR2];
		g_stcParm.stcSwProtect.u16tuvrt2 = g_u16RegParm[REG_PROTECT_TUVRT2];	
		g_stcParm.stcSwProtect.u16tuv3 = g_u16RegParm[REG_PROTECT_TUV3];
		g_stcParm.stcSwProtect.u16tuvt3 = g_u16RegParm[REG_PROTECT_TUVT3];
		g_stcParm.stcSwProtect.u16tuvr3 = g_u16RegParm[REG_PROTECT_TUVR3];
		g_stcParm.stcSwProtect.u16tuvrt3 = g_u16RegParm[REG_PROTECT_TUVRT3];	
		g_stcParm.stcSwProtect.u16difftemp1 = g_u16RegParm[REG_PROTECT_DIFFTEMP1];
		g_stcParm.stcSwProtect.u16difftempt1 = g_u16RegParm[REG_PROTECT_DIFFTEMPT1];
		g_stcParm.stcSwProtect.u16difftempr1 = g_u16RegParm[REG_PROTECT_DIFFTEMPR1];
		g_stcParm.stcSwProtect.u16difftemprt1 = g_u16RegParm[REG_PROTECT_DIFFTEMPRT1];
		g_stcParm.stcSwProtect.u16difftemp2 = g_u16RegParm[REG_PROTECT_DIFFTEMP2];
		g_stcParm.stcSwProtect.u16difftempt2 = g_u16RegParm[REG_PROTECT_DIFFTEMPT2];
		g_stcParm.stcSwProtect.u16difftempr2 = g_u16RegParm[REG_PROTECT_DIFFTEMPR2];
		g_stcParm.stcSwProtect.u16difftemprt2 = g_u16RegParm[REG_PROTECT_DIFFTEMPRT2];
		g_stcParm.stcSwProtect.u16difftemp3 = g_u16RegParm[REG_PROTECT_DIFFTEMP3];
		g_stcParm.stcSwProtect.u16difftempt3 = g_u16RegParm[REG_PROTECT_DIFFTEMPT3];
		g_stcParm.stcSwProtect.u16difftempr3 = g_u16RegParm[REG_PROTECT_DIFFTEMPR3];
		g_stcParm.stcSwProtect.u16difftemprt3 = g_u16RegParm[REG_PROTECT_DIFFTEMPRT3];
		g_stcParm.stcSwProtect.u16soclow1 = g_u16RegParm[REG_PROTECT_SOCLOW1];
		g_stcParm.stcSwProtect.u16soclowt1 = g_u16RegParm[REG_PROTECT_SOCLOWT1];
		g_stcParm.stcSwProtect.u16soclowr1 = g_u16RegParm[REG_PROTECT_SOCLOWR1];
		g_stcParm.stcSwProtect.u16soclowrt1 = g_u16RegParm[REG_PROTECT_SOCLOWRT1];
		g_stcParm.stcSwProtect.u16soclow2 = g_u16RegParm[REG_PROTECT_SOCLOW2];
		g_stcParm.stcSwProtect.u16soclowt2 = g_u16RegParm[REG_PROTECT_SOCLOWT2];
		g_stcParm.stcSwProtect.u16soclowr2 = g_u16RegParm[REG_PROTECT_SOCLOWR2];
		g_stcParm.stcSwProtect.u16soclowrt2 = g_u16RegParm[REG_PROTECT_SOCLOWRT2];
		g_stcParm.stcSwProtect.u16soclow3 = g_u16RegParm[REG_PROTECT_SOCLOW3];
		g_stcParm.stcSwProtect.u16soclowt3 = g_u16RegParm[REG_PROTECT_SOCLOWT3];
		g_stcParm.stcSwProtect.u16soclowr3 = g_u16RegParm[REG_PROTECT_SOCLOWR3];
		g_stcParm.stcSwProtect.u16soclowrt3 = g_u16RegParm[REG_PROTECT_SOCLOWRT3];		
		
		g_stcParm.stcHwProtect.u16ov = g_u16RegParm[REG_PROTECT_OV];
		g_stcParm.stcHwProtect.u16ovt = g_u16RegParm[REG_PROTECT_OVT];
		g_stcParm.stcHwProtect.u16ovr = g_u16RegParm[REG_PROTECT_OVR];
		g_stcParm.stcHwProtect.u16ovrt = g_u16RegParm[REG_PROTECT_OVRT];				
		g_stcParm.stcHwProtect.u16uv = g_u16RegParm[REG_PROTECT_UV];
		g_stcParm.stcHwProtect.u16uvt = g_u16RegParm[REG_PROTECT_UVT];
		g_stcParm.stcHwProtect.u16uvr = g_u16RegParm[REG_PROTECT_UVR];
		g_stcParm.stcHwProtect.u16uvrt = g_u16RegParm[REG_PROTECT_UVRT];	
		g_stcParm.stcHwProtect.u16occv = g_u16RegParm[REG_PROTECT_OCCV];
		g_stcParm.stcHwProtect.u16occt = g_u16RegParm[REG_PROTECT_OCCT];
		g_stcParm.stcHwProtect.u16occrv = g_u16RegParm[REG_PROTECT_OCCRV];
		g_stcParm.stcHwProtect.u16occrt = g_u16RegParm[REG_PROTECT_OCCRT];	
		g_stcParm.stcHwProtect.u16ocdv = g_u16RegParm[REG_PROTECT_OCDV];
		g_stcParm.stcHwProtect.u16ocdt = g_u16RegParm[REG_PROTECT_OCDT];
		g_stcParm.stcHwProtect.u16ocdrv = g_u16RegParm[REG_PROTECT_OCDRV];
		g_stcParm.stcHwProtect.u16ocdrt = g_u16RegParm[REG_PROTECT_OCDRT];
		g_stcParm.stcHwProtect.u16scv = g_u16RegParm[REG_PROTECT_SCV];
		g_stcParm.stcHwProtect.u16sct = g_u16RegParm[REG_PROTECT_SCT];	
		g_stcParm.stcHwProtect.i16otc = g_u16RegParm[REG_PROTECT_OTC] - TEMP_OFFSET;
		g_stcParm.stcHwProtect.u16otct = g_u16RegParm[REG_PROTECT_OTCT];
		g_stcParm.stcHwProtect.i16otcr = g_u16RegParm[REG_PROTECT_OTCR] - TEMP_OFFSET;
		g_stcParm.stcHwProtect.u16otcrt = g_u16RegParm[REG_PROTECT_OTCRT];	
		g_stcParm.stcHwProtect.i16utc = g_u16RegParm[REG_PROTECT_UTC] - TEMP_OFFSET;
		g_stcParm.stcHwProtect.u16utct = g_u16RegParm[REG_PROTECT_UTCT];
		g_stcParm.stcHwProtect.i16utcr = g_u16RegParm[REG_PROTECT_UTCR] - TEMP_OFFSET;
		g_stcParm.stcHwProtect.u16utcrt = g_u16RegParm[REG_PROTECT_UTCRT];
		g_stcParm.stcHwProtect.i16otd = g_u16RegParm[REG_PROTECT_OTD] - TEMP_OFFSET;
		g_stcParm.stcHwProtect.u16otdt = g_u16RegParm[REG_PROTECT_OTDT];
		g_stcParm.stcHwProtect.i16otdr = g_u16RegParm[REG_PROTECT_OTDR] - TEMP_OFFSET;
		g_stcParm.stcHwProtect.u16otdrt = g_u16RegParm[REG_PROTECT_OTDRT];	
		g_stcParm.stcHwProtect.i16utd = g_u16RegParm[REG_PROTECT_UTD] - TEMP_OFFSET;
		g_stcParm.stcHwProtect.u16utdt = g_u16RegParm[REG_PROTECT_UTDT];
		g_stcParm.stcHwProtect.i16utdr = g_u16RegParm[REG_PROTECT_UTDR] - TEMP_OFFSET;
		g_stcParm.stcHwProtect.u16utdrt = g_u16RegParm[REG_PROTECT_UTDRT];

		for (u8i = 0; u8i < 8; u8i++)
		{
				g_stcParm.stcCal.i16temperature[u8i] = g_u16RegParm[REG_CAL_TEMP + u8i];
		}

		for (u8i = 0; u8i < 32; u8i++)
		{
				g_stcParm.stcCal.i16voltage[u8i] = g_u16RegParm[REG_CAL_VOL + u8i];
		}
		
		g_stcParm.stcConfig.i16currZeroOffSetADVal = g_u16RegParm[REG_CAL_ZEROCUR];		
		g_stcParm.stcConfig.u16currRatioCharge = g_u16RegParm[REG_CAL_RATCHG];
		g_stcParm.stcConfig.u16currRatioDisCharge = g_u16RegParm[REG_CAL_RATDSG];

		
}

// =======================================================================================
// End of file.
// =======================================================================================
